正在使用auth0 react本机示例检索auth0id



我目前正在试用Auth0,并摆弄一个示例应用程序:https://github.com/auth0-samples/auth0-react-native-sample

我正试图联系我登录的用户并获取authId,但我得到的是客户端的详细信息:

const onLogin = () => {
auth0.webAuth
.authorize({
scope: 'openid profile email'
})
.then(credentials => {
const user = auth0.users(credentials.accessToken);
console.log(user);
Alert.alert('AccessToken: ' + credentials.accessToken);
setAccessToken(credentials.accessToken);
})
.catch(error => console.log(error));
};

结果:

{
"client": {
"telemetry": {
"name": "react-native-auth0",
"version": "2.14.1"
},
"baseUrl": "<BASE URL>",
"domain": "<DOMAIN>",
"bearer": "Bearer <TOKEN>",
"timeout": 10000
}
}

有没有办法通过这种方式获取authId?

找到了一种通过这种方式访问它的方法:

auth0.auth.userInfo({token: credentials.accessToken}).then(result => {
console.log(result);
});

最新更新