---
editLink: false
lastUpdated: false
---

[@salesforce/b2c-tooling-sdk](../../modules.md) / [auth](../index.md) / PkceWithImplicitFallbackStrategy

# Class: PkceWithImplicitFallbackStrategy

Defined in: [packages/b2c-tooling-sdk/src/auth/oauth-pkce-fallback.ts:59](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/4c2d4c5cb34e8e0ea15a260d257e468c823c4885/packages/b2c-tooling-sdk/src/auth/oauth-pkce-fallback.ts#L59)

Wraps a [PkceOAuthStrategy](PkceOAuthStrategy.md) and, on a [PkceGrantUnsupportedError](PkceGrantUnsupportedError.md),
falls back to an [ImplicitOAuthStrategy](ImplicitOAuthStrategy.md) for the same client. The
fallback is attempted at most once and then sticks for the lifetime of this
instance, so subsequent calls go straight to implicit without re-attempting
the failing PKCE flow.

## Implements

- [`UserAuthStrategy`](../interfaces/UserAuthStrategy.md)

## Constructors

### Constructor

> **new PkceWithImplicitFallbackStrategy**(`config`): `PkceWithImplicitFallbackStrategy`

Defined in: [packages/b2c-tooling-sdk/src/auth/oauth-pkce-fallback.ts:65](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/4c2d4c5cb34e8e0ea15a260d257e468c823c4885/packages/b2c-tooling-sdk/src/auth/oauth-pkce-fallback.ts#L65)

#### Parameters

##### config

[`PkceOAuthConfig`](../interfaces/PkceOAuthConfig.md)

#### Returns

`PkceWithImplicitFallbackStrategy`

## Methods

### fetch()

> **fetch**(`url`, `init`): `Promise`\<`Response`\>

Defined in: [packages/b2c-tooling-sdk/src/auth/oauth-pkce-fallback.ts:69](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/4c2d4c5cb34e8e0ea15a260d257e468c823c4885/packages/b2c-tooling-sdk/src/auth/oauth-pkce-fallback.ts#L69)

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

#### Parameters

##### url

`string`

##### init

[`FetchInit`](../type-aliases/FetchInit.md) = `{}`

#### Returns

`Promise`\<`Response`\>

#### Implementation of

[`UserAuthStrategy`](../interfaces/UserAuthStrategy.md).[`fetch`](../interfaces/UserAuthStrategy.md#fetch)

***

### getAuthorizationHeader()

> **getAuthorizationHeader**(): `Promise`\<`string`\>

Defined in: [packages/b2c-tooling-sdk/src/auth/oauth-pkce-fallback.ts:84](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/4c2d4c5cb34e8e0ea15a260d257e468c823c4885/packages/b2c-tooling-sdk/src/auth/oauth-pkce-fallback.ts#L84)

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

#### Returns

`Promise`\<`string`\>

#### Implementation of

[`UserAuthStrategy`](../interfaces/UserAuthStrategy.md).[`getAuthorizationHeader`](../interfaces/UserAuthStrategy.md#getauthorizationheader)

***

### getJWT()

> **getJWT**(): `Promise`\<[`DecodedJWT`](../interfaces/DecodedJWT.md)\>

Defined in: [packages/b2c-tooling-sdk/src/auth/oauth-pkce-fallback.ts:99](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/4c2d4c5cb34e8e0ea15a260d257e468c823c4885/packages/b2c-tooling-sdk/src/auth/oauth-pkce-fallback.ts#L99)

#### Returns

`Promise`\<[`DecodedJWT`](../interfaces/DecodedJWT.md)\>

#### Implementation of

[`UserAuthStrategy`](../interfaces/UserAuthStrategy.md).[`getJWT`](../interfaces/UserAuthStrategy.md#getjwt)

***

### getTokenResponse()

> **getTokenResponse**(): `Promise`\<[`AccessTokenResponse`](../interfaces/AccessTokenResponse.md)\>

Defined in: [packages/b2c-tooling-sdk/src/auth/oauth-pkce-fallback.ts:114](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/4c2d4c5cb34e8e0ea15a260d257e468c823c4885/packages/b2c-tooling-sdk/src/auth/oauth-pkce-fallback.ts#L114)

#### Returns

`Promise`\<[`AccessTokenResponse`](../interfaces/AccessTokenResponse.md)\>

#### Implementation of

[`UserAuthStrategy`](../interfaces/UserAuthStrategy.md).[`getTokenResponse`](../interfaces/UserAuthStrategy.md#gettokenresponse)

***

### invalidateToken()

> **invalidateToken**(): `void`

Defined in: [packages/b2c-tooling-sdk/src/auth/oauth-pkce-fallback.ts:129](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/4c2d4c5cb34e8e0ea15a260d257e468c823c4885/packages/b2c-tooling-sdk/src/auth/oauth-pkce-fallback.ts#L129)

Optional: Invalidates the cached token, forcing re-authentication on next request.
Used by middleware to retry requests after receiving a 401 response.

#### Returns

`void`

#### Implementation of

[`UserAuthStrategy`](../interfaces/UserAuthStrategy.md).[`invalidateToken`](../interfaces/UserAuthStrategy.md#invalidatetoken)
