在我的angular 6应用程序中,我配置了oktaConfig对象,如下所示,并且运行良好,没有任何问题
//okataConfig.ts
export const oktaConfig = {
url: 'https://dev-501039.oktapreview.com',
clientId: 'xxxxxxxxxxxxxxxxxxxxxx',
issuer: 'xxxxxxxxxxxxxxxxxxxxxxxxxx',
redirectUri: 'http://localhost:4200/implicit/callback',
};
//routing.ts
{path: '',component: DefaultLayoutComponent, canActivate: [AuthGuard]},
{path: 'implicit/callback',component: CallbackComponent},但是当我启用散列位置重定向不起作用时,
// app.module.ts
providers: [
{
provide: LocationStrategy,
useClass: HashLocationStrategy,
},
AuthGuard, OktaAuthService
],如何在路由中进行配置?
发布于 2020-12-28 18:16:28
在您的身份验证请求中将response_mode更改为query,而不是fragment (这会在url中添加另一个#)。这将起作用,您将获得代码和状态作为查询参数,如下所示-
http://{your.domain}/#/app/?code=xyz&state=pqr
createRequest(code_challengeBuffer, response) {
const code_challenge =
this._ssoUtilityService.bufferToBase64UrlEncoded(code_challengeBuffer);
const state = this._ssoUtilityService.createRandomString();
const nonce = this._ssoUtilityService.createRandomString();
this.appendParam('client_id', response.clientId, true);
this.appendParam('nonce', nonce, true);
this.appendParam('state', state, true);
this.appendParam('code_challenge', code_challenge, true);
this.appendParam('code_challenge_method', 'S256', true);
this.appendParam('scope', 'openid profile email offline_access', true);
this.appendParam('response_type', 'code', true);
this.appendParam('response_mode', 'query', true);
this.appendParam('redirect_uri', response.redirectUrl);
window.location.href = this.url;
}
// Added this function as IE11 does not support URL api
appendParam(key: string, value: string, addSeparator?: boolean) {
this.url += key + '=' + encodeURIComponent(value);
if (addSeparator) { this.url += '&'; }
}https://stackoverflow.com/questions/51204222
复制相似问题