如何从 Platform of Trust 获取沙盒环境中当前登录用户的 ID?

How do I get ID of the current logged-in user in the Sandbox environment from Platform of Trust?

每个注册到沙盒的用户都会作为身份添加到平台。 当我登录 Sandbox environment 时,如何获取用户的身份 ID? 我需要此用户 ID 来创建身份之间的链接,如创建组后 in this guide 所示。

使用 Platform of Trust 中 Login API/me 端点,您可以检索当前登录 Sandbox 的用户的身份 ID。

cURL 中的示例请求是:

curl -i -X GET \
   -H "Authorization: Bearer eyJ0eXAiOiJ...qW1QhdEsJLNGV2YA" \
 "https://api-sandbox.oftrust.net/me"

成功后,您应该得到以下响应:

HTTP/1.0 200

{
    "@context": "https://standards.oftrust.net/v2/Context/Identity/LegalParty/Person/",
    "@type": "Person",
    "@id": "33237067-14c3-4801-9e50-bf08406406e2",
    "email": "user@example.com",
    "role": "developer",
    "firstName": "Anna",
    "lastName": "Bar"
}

您可以从沙盒环境get your Bearer token(有效期为 24 小时)。

当您在平台中 building apps 并为目标用户创建授权流程时,您可能需要获取用户的身份 ID。

您可以访问信任登录平台的 API 文档 API here

另一种方法是登录后检查来自浏览器网络的请求: https://world-sandbox.oftrust.net/api/me

查看回复中的id