0

I was trying to get user info from login using twitter in auth0. auth0 provides userInfo api for getting users details, but it is just returning an object with a key sub (like this - {"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.

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'
    });
manjs
  • 187
  • 1
  • 16
  • 2
    the `sub` you are seeing is the user_id property - have you taken a look at the user-profile endpoint (here: https://auth0.com/docs/api/authentication#user-profile) ? did you provide `openid` for the scope of the access token? are you apply to share the code where you are making the call? – kimcodes Apr 16 '18 at 13:54
  • Yes, the scope was the point. I have given the `scope` as **'openid'**. But when I just changed `scope` as **'openid profile'**, it worked. Thanks! – manjs Apr 17 '18 at 05:42
  • woo great! :) glad it worked. – kimcodes Apr 17 '18 at 13:03

1 Answers1

1

The question does not offer any details on how you are making the authentication request with Twitter social connection. At a minimum, suggest that you try adding scope: openid profile email to your authentication request. That will ensure the id_token returned contains all OIDC conformant user profile attributes (claims).

Please see the documentation for details.

If you visit the auth0 dashboard social connections you can see what twitter returns to Auth0. With OIDC conformance enabled you can expect to see at least basic info like sub (user id), name, and picture. Screenshot below - please make sure you did tick the checkbox for Basic Profile user consent.

enter image description here

arcseldon
  • 35,523
  • 17
  • 121
  • 125
  • `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' });` this was the config. As @kimcodes mentioned about scope, I found that the problem is in the scope and modified as **openid profile** it worked. – manjs Apr 17 '18 at 05:49
  • @manjs - please can you mark this answer correct - have highlighted the need to add `openid profile email` - it would help others visiting this question to have trust in the answer provided - disclaimer, i also work at Auth0 ;) – arcseldon Apr 17 '18 at 12:47