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):
namegiven_namefamily_nameemailpreferred_usernameoidsubgroupsroleslocalephone_number
Graph-shaped aliases, populated from the OIDC claims above:
displayName←namegivenName←given_namesurname←family_namemail←emailuserPrincipalName←preferred_usernameid←oid ?? submobilePhone←phone_numberpreferredLanguage←locale
Graph fields with no OIDC equivalent — jobTitle, officeLocation,
businessPhones — are not populated.
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>
Property |
Type |
Required |
Notes |
|---|---|---|---|
idToken |
string |
No |
An OIDC id_token JWT. If omitted, returns |