0

我正在使用 angular-oauth2-oidc 进行身份验证,但我不知道如何获取访问令牌。我正在使用带有此配置的 PKCE 代码流

  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
  };

使用此代码启动流程,登录后将其重定向,但我无法获得任何令牌。

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

1 回答 1

1

在上面的示例中,通过发送客户端密码解决了问题

   dummyClientSecret: 'test',

我正在使用似乎需要客户端密码的 Cloud Foundry 授权服务器。然后可以很容易地获得访问令牌

this.oauthService.getAccessToken()

版本:

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

我不会删除这个问题,以防将来有人遇到同样的问题。

于 2022-02-08T10:28:26.073 回答