如何获得用户's在wso2api管理器中的配置文件

How to get user's profile in wso2 api manager?

本文关键字:管理器 wso2api 配置文件 用户 何获得      更新时间:2024-03-01

我需要在wso2api管理器中获取用户配置文件,我该怎么做?到目前为止,我已经完成了获取访问令牌、刷新令牌和撤销令牌:

https://localhost:9443/oauth2/token --> access and refresh token
https://localhost:9443/oauth2/revoke --> revoke token

谢谢你的帮助。

如果您将openid定义为作用域之一,那么您将能够使用userinfo端点来获取与用户相关的信息。

生成具有作用域openid 的令牌

curl -k -d "grant_type=password&username=admin&password=admin&scope=openid" -H "Authorization: Basic NzhfQURZNGdBMWJ6djd0ZVc0Zk11VkpMM0xVYTpQWE55RmZ1ZjlmbkVhUW9NYksyaUxjTFE1dndh" https://localhost:9443/oauth2/token

使用该令牌请求userinfo

curl -k  -H "Authorization: Bearer 14e78b764c91a1f18b5566ddbd88c5ff" https://localhost:9443/oauth2/userinfo?schema=openid

默认情况下,响应只包含子值。{"sub":admin@carbon.super"}

您可以通过在API Manager 中配置服务提供应用程序中的声明来定义应发送的参数

登录碳管理控制台并选择服务提供商应用程序

在索赔配置下,您可以将电子邮件、姓氏和任何其他需要的索赔设置为"请求索赔"

ex: http://wso2.org/claims/emailaddress for email

一旦配置好,您将得到以下类型的对先前请求的响应

{"sub":"admin@carbon.super","family_name":"adhikarinayake","email":"chamilaa@wso2.com"}