我知道我需要在令牌中附加声明才能接收 org_id。 问题是 - 我应该将其附加到 ID 令牌还是访问令牌吗?在 auth0 文档中,它被附加到两者 - https://auth0.com/docs/manage-users/organizations/using-tokens#authenticate-users-through-an-organization
那么下一个问题是,我如何将其实际附加到令牌中?我已经创建了组织,启用了所需的设置,通过仪表板添加了角色和权限,但我认为最后缺少的是创建我假设的自定义操作?
有什么想法吗?
我尝试了这个例子,但没有运气 - https://community.auth0.com/t/how-to-add-roles-and-permissions-to-the-id-token-using-actions/84506
我认为您可能误读了 auth0 文档。这并不是说您必须将 org_id 附加到令牌中。相反,当您重定向用户进行授权时,您需要传递 org_id 作为查询参数(这会命中 auth0 的
/authorize
端点)。所以你的请求看起来像这样:
https://{yourDomain}/authorize?
response_type=code&
client_id={yourClientId}&
redirect_uri={https://yourApp/callback}&
scope={scope}&
state={state}&
organization={yourOrganizationId}
当您向组织进行身份验证时,auth0 会将其添加到您的令牌中。