getUserInfo

Overview

Decodes an OIDC id_token JWT and returns the claims object. Works with any OIDC-compliant provider (Indigo IAM, Entra ID, …).

The returned object contains the standard OIDC claims plus a compatibility shim of Graph-shaped aliases for callers migrating from the previous MS Graph /me behaviour.

OIDC claims (a representative subset):

  • name

  • given_name

  • family_name

  • email

  • preferred_username

  • oid

  • sub

  • groups

  • roles

  • locale

  • phone_number

Graph-shaped aliases, populated from the OIDC claims above:

  • displayNamename

  • givenNamegiven_name

  • surnamefamily_name

  • mailemail

  • userPrincipalNamepreferred_username

  • idoid ?? sub

  • mobilePhonephone_number

  • preferredLanguagelocale

Graph fields with no OIDC equivalent — jobTitle, officeLocation, businessPhones — are not populated.

Example : Default usage
import { useMsal } from '@azure/msal-react';
import { getUserInfo } from '@ska-telescope/ska-login-page';

...

const { accounts } = useMsal();
const idToken = accounts[0]?.idToken;

const [userInfo, setUserInfo] = React.useState<Record<string, unknown> | null>(null);
getUserInfo(idToken).then((response) => {
   setUserInfo(response);
});

...

<p>
     <strong>Name</strong> {userInfo?.name}      {/* or userInfo?.displayName */}
</p>
Properties

Property

Type

Required

Notes

idToken

string

No

An OIDC id_token JWT. If omitted, returns null. Passing an access_token instead emits a one-shot console.warn but the token is still decoded.