Skip to main content

Class: OAuthManagementClient

Defined in: src/management/oauth-management.ts:30

Client for OAuth token management operations.

Constructors​

Constructor​

new OAuthManagementClient(opts): OAuthManagementClient;

Defined in: src/management/oauth-management.ts:35

Parameters​

ParameterType
optsOAuthManagementClientOptions

Returns​

OAuthManagementClient

Methods​

invalidateToken()​

invalidateToken(token, body): Promise<string>;

Defined in: src/management/oauth-management.ts:58

Invalidate an OAuth token.

Parameters​

ParameterTypeDescription
tokenstringThe OAuth token to invalidate.
bodyobjectOutputTypeClient ID and customer app.

Returns​

Promise<string>

Confirmation string.

Example​

import { ManagementClient } from '@cdot65/prisma-airs-sdk';
const mgmt = new ManagementClient(); // reads PANW_MGMT_* env vars

const result = await mgmt.oauth.invalidateToken('old-token', {
client_id: 'cid',
customer_app: 'app1',
});
// result => 'token invalidated'

getAccessToken()​

getAccessToken(opts): Promise<objectOutputType<{
token_type: ZodOptional<ZodString>;
issued_at: ZodOptional<ZodString>;
client_id: ZodOptional<ZodString>;
access_token: ZodString;
expires_in: ZodOptional<ZodString>;
status: ZodOptional<ZodString>;
}, ZodTypeAny, "passthrough">>;

Defined in: src/management/oauth-management.ts:90

Get an OAuth token for client credentials.

Parameters​

ParameterTypeDescription
optsGetTokenOptionsToken request options.

Returns​

Promise<objectOutputType<{ token_type: ZodOptional<ZodString>; issued_at: ZodOptional<ZodString>; client_id: ZodOptional<ZodString>; access_token: ZodString; expires_in: ZodOptional<ZodString>; status: ZodOptional<ZodString>; }, ZodTypeAny, "passthrough">>

OAuth2 token response.

Example​

import { ManagementClient } from '@cdot65/prisma-airs-sdk';
const mgmt = new ManagementClient(); // reads PANW_MGMT_* env vars

const token = await mgmt.oauth.getAccessToken({
body: { client_id: 'cid', customer_app: 'app1' },
tokenTtlInterval: 3,
tokenTtlUnit: 'hours',
});
// token =>
// { access_token: 'new-token', expires_in: '86400', token_type: 'Bearer' }