Skip to content

Expose PKCE code_verifier through a public API for backend token exchange flows #1499

Description

@Gunyon

Is your feature request related to a problem? Please describe.
We are using angular-oauth2-oidc in an Angular SPA with Authorization Code Flow + PKCE.

Our architecture is multi-tenant SSO:

  • each customer can have its own external Identity Provider;
  • the frontend starts the OIDC login flow;
  • the frontend receives the authorization code on the callback route;
  • our own backend performs the token exchange with the customer IDP;
  • the backend then maps external identity claims to internal users, roles, permissions, company restrictions, and issues our application session/token.

This means the frontend needs to send the backend:

  • code
  • redirectUri
  • issuer / tenant SSO identifier
  • code_verifier

Currently, angular-oauth2-oidc correctly generates and stores the PKCE verifier when initCodeFlow() is called, but there does not appear to be a public API to retrieve that verifier. The verifier is stored internally in OAuthStorage under the key PKCE_verifier, so the only practical option is to read that internal key manually.

Example current workaround:

const codeVerifier = oauthStorage.getItem('PKCE_verifier');

Describe the solution you'd like
Provide a public API to retrieve the current PKCE code_verifier (if present) after initCodeFlow() has been called, so that applications with backend exchange logic can easily access the value and send it securely to the backend for direct OIDC token exchange.

Describe alternatives you've considered

  • Reading the PKCE verifier directly out of the OAuthStorage with the internal key (PKCE_verifier), which is brittle and not future-proof.
  • Refactoring our flows to avoid backend token exchange, which is not feasible due to business requirements.

Additional context
This would help support architectures where the SPA acts as the OIDC Auth frontend but backend services need to process the actual token exchange for maximum security, audit logging, claim customization, etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions