无法控制台日志 Auth0 user_metadata。我创建了自定义规则 我也看到 postman.What 中的数据 我做错了吗
Not be able to console log Auth0 user_metadata. I created a custom rule I also see the data in postman.What am I doing wrong
** 我正在做如下,我已经创建了一个自定义规则。**
componentDidMount() {
console.log(token)
let response = fetch('https://DOmain.eu.auth0.com/userinfo', {
method: 'GET',
headers: {
Authorization: 'Bearer ' + token,
},
}).then((response) => response.json())
.then(responseJson => data = responseJson).then(console.log(data.nickname));
const metadata = data["https://Domain.eu.auth0.com/user_metadata"]
console.log(metadata);
}
我的规则:
您设置的 Rule 看起来不错,但无法正常工作,因为命名空间是 Auth0 域
Any non-Auth0 HTTP or HTTPS URL can be used as a namespace identifier,
and any number of namespaces can be used
尝试使用备用命名空间,例如 'https://myapp.example.com/'
,您应该可以开始了!
作为旁注,我会尽量避免将所有 usermetadata
添加到 idtoken
中,这会导致生成的令牌太大。您还应确保包含的数据不敏感且可以披露。一些可能有用的项目,请快速阅读此处:https://auth0.com/docs/metadata and here: https://auth0.com/docs/scopes/current/custom-claims 以帮助您一路走来!
** 我正在做如下,我已经创建了一个自定义规则。**
componentDidMount() {
console.log(token)
let response = fetch('https://DOmain.eu.auth0.com/userinfo', {
method: 'GET',
headers: {
Authorization: 'Bearer ' + token,
},
}).then((response) => response.json())
.then(responseJson => data = responseJson).then(console.log(data.nickname));
const metadata = data["https://Domain.eu.auth0.com/user_metadata"]
console.log(metadata);
}
我的规则:
您设置的 Rule 看起来不错,但无法正常工作,因为命名空间是 Auth0 域
Any non-Auth0 HTTP or HTTPS URL can be used as a namespace identifier, and any number of namespaces can be used
尝试使用备用命名空间,例如 'https://myapp.example.com/'
,您应该可以开始了!
作为旁注,我会尽量避免将所有 usermetadata
添加到 idtoken
中,这会导致生成的令牌太大。您还应确保包含的数据不敏感且可以披露。一些可能有用的项目,请快速阅读此处:https://auth0.com/docs/metadata and here: https://auth0.com/docs/scopes/current/custom-claims 以帮助您一路走来!