Clarification on id_token vs access_token

≡放荡痞女 提交于 2019-11-30 11:08:19

Your frontent is your OAuth client application, once it stores the token and can take actions on the OAuth flow. And your API service is resource serve, because it accepts the access_token issued by your identity server.

Also I would say that your id_token stands for the identification of the logged user and may contain sensitive data for your app. The access_token is standing as your credential to access a resouce.

At the end you will use an access_token to request a resource, and than if you need specific data from the logged in user (resource owner), you may request the ID token from the token endpoint.

In my opinion, the first approach is correct. Your SPA is the client application and your APIs are resource servers.

I would suggest you limit the use of id_token till your SPA only. You can use the basic information present in the id token (like username and email) to display user information within your UI. If you can generate access tokens as JWTs too then your API can validate the access tokens without going to the Identity provider. You can include roles (or similar) in your access token to get authorization information in your access token.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!