react-oidc icon indicating copy to clipboard operation
react-oidc copied to clipboard

UserData user info is always undefined

Open VGamezz19 opened this issue 4 years ago • 0 comments

I simply try to catch user information from const { user, userManager }= useContext(UserData); but they are always null :(

Console Log Output

{user: null, userManager: null, signOut: ƒ}

Is there any configuration that I have missed related on UserData context?

There you have my user manager config:

export const METADATA_OIDC = {
  issuer: IDENTITY_URL,
  jwks_uri: `${IDENTITY_URL}/.well-known/openid-configuration/jwks`,
  authorization_endpoint: `${IDENTITY_URL}/connect/authorize`,
  token_endpoint: `${IDENTITY_URL}/connect/token`,
  userinfo_endpoint: `${IDENTITY_URL}/connect/userinfo`,
  end_session_endpoint: `${IDENTITY_URL}/connect/endsession`,
  check_session_iframe: `${IDENTITY_URL}/connect/checksession`,
  revocation_endpoint: `${IDENTITY_URL}/connect/revocation`,
  introspection_endpoint: `${IDENTITY_URL}/connect/introspect`
};

export const IDENTITY_CONFIG = {
  authority: IDENTITY_URL,
  client_id: 'jscmms',
  redirect_uri: `${HOST_URL}/callback`,
  login: `${IDENTITY_URL}/login`,
  automaticSilentRenew: true,
  filterProtocolClaims: true,
  loadUserInfo: true,
  silent_redirect_uri: `${HOST_URL}/renew`,
  post_logout_redirect_uri: `${HOST_URL}/`,
  response_type: 'token id_token',
  scope: 'openid profile'
};

export const userManager = makeUserManager({
  ...IDENTITY_CONFIG,
  metadata: {
    ...METADATA_OIDC
  }
});

There you have how I implement it

  return makeAuthenticator({
    userManager,
    signinArgs: {
      extraQueryParams: {
        site: SITE_ID
      }
    }
  })(Component);

Tnx for your time

VGamezz19 avatar Dec 17 '20 14:12 VGamezz19