简体   繁体   English

如何从不记名令牌转换为实体ID?

[英]How to go from bearer token to entity id?

Likely a noob question which is answered best by pointing to something else than the direct answer, BUT: 可能有一个菜鸟问题,通过指向除直接答案(BUT)以外的其他内容,可以最好地解决这个问题:

I have setup a web api with identity authentication. 我已经设置了带有身份验证的Web API。 When someone logs in they login with email/password by calling /token , which gives them the bearer token they can use. 当某人登录时,他们通过调用/token使用电子邮件/密码登录,这为他们提供了可以使用的承载令牌。

However, what is the best practice to get company settings? 但是,获得公司设置的最佳实践是什么? Is that calling an /customer?email=email ? 那是打/customer?email=email吗? I guess my question really is: How do you go from token to customerid for instance? 我想我的问题确实是:例如,您如何从令牌变成客户ID?

Since you are already creating a bearer token, you can put anything you want or need inside the token as claims. 由于您已经在创建不记名令牌,因此可以将所需的任何内容放入令牌中作为声明。

If the company is not related to your account, then the beginning of your question (about the /token endpoint) is irrelevant, 如果公司与您的帐户无关,则问题的开头(关于/ token端点)是不相关的,

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

相关问题 可以使用 OIDC ID 令牌作为从 SPA 到无状态 C# 后端的不记名令牌吗? - OK to use OIDC ID token as bearer token from SPA to stateless C# backend? 从承载令牌生成身份 - Generate Identity from bearer token 从承载令牌中获取信息 - Get information from bearer token 如何从WsFederationAuthentication获取承载令牌以发送到API - How to get bearer token from WsFederationAuthentication to send to API 如何从asp.net获取承载令牌作为http响应 - How to get bearer token as http response from asp.net 如何将角色添加到ASP身份承载令牌 - How to add roles to the asp identity bearer token 如何撤销不记名令牌(无刷新)? - How to revoke a bearer token (w/o refresh)? 如何通过url查询字符串在前端保存承载令牌? ASP.NET中的RESTful API - How to save a bearer token in front end from a url query string? RESTful api in ASP.NET 实现Identity 2.1 + OWIN OAuth JWT承载令牌时如何从Web API控制器端点进行身份验证 - How to authenticate from Web API controller endpoint when implementing Identity 2.1 + OWIN OAuth JWT bearer token 如何获取和使用承载令牌从WPF C#中的API控制器获取数据? - How to get and use bearer token to get data from API Controller in WPF C#?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM