简体   繁体   English

从oAuth2访问令牌API管理器获取用户名

[英]Get username from oAuth2 access token API Manager

The use case occurs once user is authenticated and obtain an oAuth2 access token from Wso2 API Manager and we want to obtain username again from this access token. 用户通过身份验证后会出现用例,并从Wso2 API Manager获取oAuth2访问令牌,我们希望再次从此访问令牌获取用户名。

To obtain access token I've followed normal steps published on: [API Manager] ( http://docs.wso2.org/display/AM160/Token+API#TokenAPI-GeneratingaccesstokenswithusercredentialspasswordgranttypeGenerating ) 要获取访问令牌,我按照以下常规步骤发布:[API Manager]( http://docs.wso2.org/display/AM160/Token+API#TokenAPI-GeneratingaccesstokenswithusercredentialspasswordgranttypeGenerating

Does WSO2 AM provide any REST method to solve it? WSO2 AM是否提供任何REST方法来解决它?

Yes.. There would be two ways that you can obtain user name 是..您可以通过两种方式获取用户名

  1. APIM would return the user name with the Access token. APIM将使用Access令牌返回用户名。 Here user name would be embedded with the access token. 此处用户名将嵌入访问令牌。 You can find more details from here 您可以在此处找到更多详细信息

  2. You can obtain the user name and user's attribute during access token verification process. 您可以在访问令牌验证过程中获取用户名和用户的属性。 Once access token is verified successfully, It would return back with JWT token which contains user's attributes. 成功验证访问令牌后,它将返回包含用户属性的JWT令牌。 Then you can extract use name from JWT. 然后,您可以从JWT中提取使用名称。 You find more details on here . 你在这里找到更多细节。 Basically inside the APIM, you can extract JWT token in transport header. 基本上在APIM内部,您可以在传输头中提取JWT令牌。 But, if you want to retrieve the JWT token for the use of your application, you can send the access token to "OAuth2TokenValidationService" service and validate it and then it return back with JWT. 但是,如果要检索JWT令牌以供应用程序使用,可以将访问令牌发送到“OAuth2TokenValidationService”服务并对其进行验证,然后使用JWT返回。 (But "OAuth2TokenValidationService" is a web service.). (但“OAuth2TokenValidationService”是一种Web服务。)。 You can use web service client to invoke this service (such as SOAPUI) 您可以使用Web服务客户端来调用此服务(例如SOAPUI)

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

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