angularoauth-2.0pkceangular-oauth2-oidc

How to get access token using angular-oauth2-oidc for PKCE code authentication?


I am using angular-oauth2-oidc for authentication and I dont know how to get access token. I am using PKCE code flow with this configuraion

  authConfig: AuthConfig = {
    issuer: 'https://test.com/oauth/token',
    // requireHttps: false,
    redirectUri:'http://localhost:4200/',
    strictDiscoveryDocumentValidation: false,
    tokenEndpoint: 'https://test.com/oauth/token',
    clientId: 'test',
    // dummyClientSecret: 'test',
    scope: 'openid',
    oidc: true,
    responseType: 'code',
    showDebugInformation: true,
    requestAccessToken: true
  };

Flow is initiated with this code and after login it's redirected but I can't get any tokens.

  getAutherizationCodeWithPKCE() {
    this.oauthService.configure(this.authConfig);
    this.oauthService.initCodeFlow();
    this.oauthService.loadDiscoveryDocumentAndTryLogin
}

Solution

  • Issue is resolved with sending client secret in the example above

       dummyClientSecret: 'test',
    

    I am using Cloud Foundry authorization server that seems to require client secret. Access token then can be easily obtained with

    this.oauthService.getAccessToken()
    

    versions:

    angular 13.1.2
    angular-oauth2-oidc 13.0.1
    cloud foundry uaa 75.11.0
    

    I am not deleting this question in case someone get same issue in the future.