[英]get auth0 user metadata as part of user information
I don't find how to get the user_metadata from the Auth0 Authentication api: 我没有找到如何从Auth0身份验证API获取user_metadata:
$auth0Api = new Authentication($domain, $clientId, $clientSecret);
$tokenInfo = $auth0Api->login([
'username' => $username,
'password' => $password,
'realm' => 'Username-Password-Authentication',
]);
$accessToken = $tokenInfo["access_token"];
$info = $auth0Api->userinfo($accessToken);
The final $info
array only contains the main user information, no meta_data at all. 最终的$info
数组只包含主要用户信息,根本没有meta_data。 I tried creating a rule from the Auth0 side to add stuff to the user itself (doing user.customtag = 'helloworld'
for example) and the customization does not show either. 我尝试从Auth0方面创建一个规则来向用户自己添加内容(例如,执行user.customtag = 'helloworld'
),并且自定义也没有显示。
User info retrieved: 检索到用户信息:
{
"sub":"auth0|XXXX",
"name":"XXXX@XXXX.com",
"nickname":"XXXX",
"picture":"XXXX.png",
"updated_at":"2017-03-31T08:50:59.819Z",
"email":"XXXX@XXXX.com",
"email_verified":true
}
The "Raw Json" tab of that user shows something much more complete: 该用户的“Raw Json”选项卡显示更完整的内容:
{
"email": "XXXX@XXXX.com",
"email_verified": true,
"user_id": "auth0|XXXX",
"picture": "XXXX.png",
"nickname": "XXXX",
"identities": [
{
"user_id": "XXXX",
"provider": "auth0",
"connection": "Username-Password-Authentication",
"isSocial": false
}
],
"updated_at": "2017-03-31T08:50:59.819Z",
"created_at": "2017-03-23T16:03:47.075Z",
"name": "XXXX",
"user_metadata": {
"languageCode": "EN"
},
"last_ip": "XXXX",
"last_login": "XXXX",
"logins_count": XXXX,
"blocked_for": [],
"guardian_enrollments": []
}
How is it supposed to work? 它应该如何工作?
Environment: 环境:
Try starting up your application locally, then update the following URL with your own settings and paste it into a web browser: 尝试在本地启动应用程序,然后使用您自己的设置更新以下URL并将其粘贴到Web浏览器中:
https://YOUR_TENANT.auth0.com/authorize?client_id=YOUR_CLIENT_ID&response_type=code&scope=openid profile&redirect_uri=YOUR_REDIRECT_URI&nonce=12345
This should at least ensure you are making a request with right scopes etc. You should also ensure you have a User Profile with some "metadata" assigned if you are expecting to read that data post authentication of course ;) 这至少应该确保您使用正确的范围等来发出请求。如果您希望在认证后读取该数据,您还应该确保您拥有一个分配了一些“元数据”的用户配置文件;)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.