【问题标题】:How to get access token using angular-oauth2-oidc for PKCE code authentication?如何使用 angular-oauth2-oidc 获取访问令牌以进行 PKCE 代码身份验证?
【发布时间】:2022-02-08 18:28:26
【问题描述】:

我正在使用 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
}

【问题讨论】:

标签: angular oauth-2.0 pkce angular-oauth2-oidc angular-auth-oidc-client


【解决方案1】:

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

   dummyClientSecret: 'test',

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

this.oauthService.getAccessToken()

版本:

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

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

【讨论】:

    猜你喜欢
    • 2020-09-25
    • 2017-09-24
    • 2016-09-15
    • 2020-03-03
    • 1970-01-01
    • 1970-01-01
    • 2018-09-07
    • 2014-02-11
    • 2023-03-20
    相关资源
    最近更新 更多