简体   繁体   English

从 Auth0 请求中获取访问令牌

[英]Get access token from Auth0 request

I am configuring auth0 to be used with React.我正在配置 auth0 以与 React 一起使用。 I was able to follow this guide and get it working:我能够遵循本指南并使其正常工作:

https://auth0.com/docs/quickstart/spa/react#configure-auth0 https://auth0.com/docs/quickstart/spa/react#configure-auth0

However I am not able to figure out how I get the access code.但是,我无法弄清楚如何获得访问代码。 I would like to take that and store it in my database along with other information from the user/ personal information as well as store it in a redux store for use with my backend database to link the user to the data.我想将它与来自用户/个人信息的其他信息一起存储在我的数据库中,并将其存储在 redux 存储中,以便与我的后端数据库一起使用以将用户链接到数据。

When a user logs in, Auth0 returns three items:

access_token,
id_token,
expires_in

You can use these items in your application to set up and manage authentication.

Would appreciate any pointers with how to get the access and id tokens using the hooks format shown above.将不胜感激任何有关如何使用上面显示的钩子格式获取访问和 id 令牌的指针。

It sounds like you might be looking for the credentials-exchange extensibility point hook as it allows you to change the scopes and add custom claims to the Access Tokens issued by the Auth0 API's POST /oauth/token endpoint during runtime.听起来您可能正在寻找凭证交换扩展点挂钩,因为它允许您在运行时更改范围并向 Auth0 API 的 POST /oauth/token端点发出的访问令牌添加自定义声明。 This would be beneficial to feed off those custom claims and store as you previously mentioned.正如您之前提到的,这将有利于满足那些自定义声明和存储。 Hooks are very powerful when setup correctly so be sure to let us know if you have any questions!正确设置后,Hooks 非常强大,因此如果您有任何问题,请务必告诉我们!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM