4

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
}
FabianGosebrink
  • 305
  • 2
  • 12
playerone
  • 987
  • 3
  • 22
  • 44
  • Check this [sample project](https://github.com/jeroenheijmans/sample-angular-oauth2-oidc-with-auth-guards) referenced from the angular-oauth2-oidc github and its [auth.service.ts](https://github.com/jeroenheijmans/sample-angular-oauth2-oidc-with-auth-guards/blob/master/src/app/core/auth.service.ts). – Ján Halaša Feb 08 '22 at 06:39
  • this is the older project and I am using PKCE flow. – playerone Feb 08 '22 at 10:20

1 Answers1

6

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.

playerone
  • 987
  • 3
  • 22
  • 44