简体   繁体   English

如何在使用auth0进行身份验证的React应用中获取用户信息

[英]How to get user info in a react app which uses auth0 for authentication

I was trying to get user info from login using twitter in auth0. 我正在尝试使用auth0中的twitter从登录获取用户信息。 auth0 provides userInfo api for getting users details, but it is just returning an object with a key sub (like this - {"sub":"twitter|XXXXXXXXX"} ). auth0提供用于获取用户详细信息的userInfo api ,但它只是返回带有键子的对象(例如- {"sub":"twitter|XXXXXXXXX"} )。 As per the documentation provided, we should get the name, picture, nickname etc, in my case only one sub is returning. 根据提供的文档 ,我们应该获得名称,图片,昵称等,在我的情况下,仅返回一个子项 I wanted to know how the details of user can be fetched in auth0. 我想知道如何在auth0中获取用户的详细信息。

edit - providing the configs used. 编辑-提供使用的配置。

auth0 = new auth0.WebAuth({
        domain: AUTH_CONFIG.domain,
        clientID: AUTH_CONFIG.clientId,
        redirectUri: AUTH_CONFIG.callbackUrl,
        audience: `https://${AUTH_CONFIG.domain}/userinfo`,
        responseType: 'token id_token',
        scope: 'openid'
    });

The question does not offer any details on how you are making the authentication request with Twitter social connection. 该问题未提供有关如何通过Twitter社交连接发出身份验证请求的任何详细信息。 At a minimum, suggest that you try adding scope: openid profile email to your authentication request. 至少,建议您尝试将scope: openid profile email添加到身份验证请求中。 That will ensure the id_token returned contains all OIDC conformant user profile attributes (claims). 这将确保返回的id_token包含所有符合OIDC的用户配置文件属性(声明)。

Please see the documentation for details. 请参阅文档以了解详细信息。

If you visit the auth0 dashboard social connections you can see what twitter returns to Auth0. 如果您访问auth0仪表板社交关系 ,则可以看到Twitter返回到Auth0的内容。 With OIDC conformance enabled you can expect to see at least basic info like sub (user id), name , and picture . 启用OIDC一致性后,您至少可以看到基本信息,例如sub (用户ID), namepicture Screenshot below - please make sure you did tick the checkbox for Basic Profile user consent. 下面的屏幕截图-请确保您已选中“基本个人资料”用户同意复选框。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM