Skip to content

@salesforce/b2c-tooling-sdk / auth / OAuthStrategy

Class: OAuthStrategy ​

Defined in: packages/b2c-tooling-sdk/src/auth/oauth.ts:34

Implements ​

Constructors ​

Constructor ​

new OAuthStrategy(config): OAuthStrategy

Defined in: packages/b2c-tooling-sdk/src/auth/oauth.ts:38

Parameters ​

config ​

OAuthConfig

Returns ​

OAuthStrategy

Methods ​

fetch() ​

fetch(url, init): Promise<Response>

Defined in: packages/b2c-tooling-sdk/src/auth/oauth.ts:42

Performs a fetch request with authentication. Implementations MUST handle header injection and 401 retries (token refresh) internally.

Parameters ​

url ​

string

init ​

FetchInit = {}

Returns ​

Promise<Response>

Implementation of ​

AuthStrategy.fetch


getAuthorizationHeader() ​

getAuthorizationHeader(): Promise<string>

Defined in: packages/b2c-tooling-sdk/src/auth/oauth.ts:70

Optional: Helper for legacy clients (like a strict WebDAV lib) that need the raw header.

Returns ​

Promise<string>

Implementation of ​

AuthStrategy.getAuthorizationHeader


getJWT() ​

getJWT(): Promise<DecodedJWT>

Defined in: packages/b2c-tooling-sdk/src/auth/oauth.ts:78

Gets the decoded JWT payload

Returns ​

Promise<DecodedJWT>


getTokenResponse() ​

getTokenResponse(): Promise<AccessTokenResponse>

Defined in: packages/b2c-tooling-sdk/src/auth/oauth.ts:87

Gets the full token response including expiration and scopes. Useful for commands that need to display or return token metadata.

Returns ​

Promise<AccessTokenResponse>


invalidateToken() ​

invalidateToken(): void

Defined in: packages/b2c-tooling-sdk/src/auth/oauth.ts:111

Invalidates the cached token, forcing re-authentication on next request

Returns ​

void

Implementation of ​

AuthStrategy.invalidateToken


withAdditionalScopes() ​

withAdditionalScopes(additionalScopes): OAuthStrategy

Defined in: packages/b2c-tooling-sdk/src/auth/oauth.ts:122

Creates a new OAuthStrategy with additional scopes merged in. Used by clients that have specific scope requirements.

Parameters ​

additionalScopes ​

string[]

Scopes to add to this strategy's existing scopes

Returns ​

OAuthStrategy

A new OAuthStrategy instance with merged scopes

Released under the Apache-2.0 License.