【发布时间】: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