【问题标题】:Getting id_token as null in OIDC when sending responseType = 'id_token'发送 responseType = 'id_token' 时在 OIDC 中将 id_token 设为 null
【发布时间】:2020-03-31 05:06:51
【问题描述】:

我正在使用 OKTA,登录后获取 id_token 作为 url 中的响应。问题是每当我调用 this.oauthService.getIdToken() 时,我都会得到空值。下面是我的配置。

import { AuthConfig } from 'angular-oauth2-oidc';

export const authConfig: AuthConfig = {
  issuer: 'https://dev-350189.okta.com',
  clientId: "XXXXXXX",
  logoutUrl: "https://dev-350189.okta.com/oauth2/v1/logout",
  redirectUri: window.location.origin +'/home',
  scope: 'openid profile',
  responseType: 'id_token',
  oidc: true,
  requestAccessToken: true,
  showDebugInformation: true,
  clearHashAfterLogin: false,
}

app.component.ts

private configure() {
        this.oauthService.configure(authConfig);
        this.oauthService.setStorage(localStorage);
        this.oauthService.tokenValidationHandler = new JwksValidationHandler();

        this.oauthService.createAndSaveNonce().then(nonce => {
            console.log('Nonce generated', nonce);
            this.oauthService.customQueryParams = { "nonce": nonce };

            // Load Discovery Document and then try to login the user
            this.oauthService.loadDiscoveryDocument().then(() => {
                this.oauthService.tryLogin().then(() => {
                    console.log("final output");
                    console.log(this.oauthService.getIdToken());
                });
            });
        });
    }

请帮助我两天以来一直在苦苦挣扎的人。

【问题讨论】:

    标签: openid-connect okta


    【解决方案1】:

    我有一个可以工作的 Okta 示例,它可能会有所帮助 - 尝试使用与 my settings 等效的设置。

    如今最标准的流程是 response_type='code',意思是授权代码流程 (PKCE) - Okta 完全支持。

    如果对示例有帮助,则该示例有一个链接到一些博客文章的 README 文件

    【讨论】:

      猜你喜欢
      • 2018-11-14
      • 1970-01-01
      • 1970-01-01
      • 2021-08-08
      • 2018-07-23
      • 2020-03-11
      • 2017-09-30
      • 2019-06-27
      • 2019-02-11
      相关资源
      最近更新 更多