Jer*_*oen 2 auth0 angular angular-oauth2-oidc
我在angular-oauth2-oidc图书馆设置为使用与Auth0。但是,Auth0 不断向我发送一个非常短的访问令牌,例如mSNhEfdDHK6t-kT5QweRtgec-FPGAsdfEw9,而不是完整的 JWT 令牌。以下是重现问题的方法:
angular-oauth2-oidc或克隆我的示例 repo。按照以下方式配置它:
export const authConfig: AuthConfig = {
issuer: 'https://your-tenant-name.eu.auth0.com/',
clientId: 'your-spa-client-id-here',
redirectUri: window.location.origin + '/index.html',
scope: 'openid profile email',
};
Run Code Online (Sandbox Code Playgroud)initImplicitFlow()通过单击应用程序上的登录按钮触发调用。
当你这样做时:
Auth0 社区论坛上有一个线程,它解释了为什么您会为访问令牌获得这样一个“不透明字符串”。最重要的、被接受的答案提到了我已经在做的事情(sope就像我所做的那样,打电话/authorize等)。但是,在该线程的较低部分提到设置audience调用时/authorize是解决方案,无论如何这似乎是一件好事。
但是你如何发送audience?有上没有这样的属性的AuthConfig类型来设置它,看initImplicitFlow()它只是直线上升的变化源location.href,所以没有拦截有两种。
你快到了。虽然它可能是不错的audience作为对一个特定的属性AuthConfig类型,已经有配置它的方式:使用了customQueryParams这个:
export const authConfig: AuthConfig = {
issuer: 'https://your-tenant-name.eu.auth0.com/',
clientId: 'your-spa-client-id-here',
redirectUri: window.location.origin + '/index.html',
scope: 'openid profile email',
customQueryParams: {
audience: 'https://your-api-audience-id.example.com',
},
};
Run Code Online (Sandbox Code Playgroud)
该audience是你在Auth0配置的标识符。这是管理界面的截图:
| 归档时间: |
|
| 查看次数: |
1361 次 |
| 最近记录: |