Open pavdev64 opened 4 months ago
hi @pavdev64 , Thank you for you issue.
undefined is not a normal behavior. Do you have an error in your console?
What happen if you set up your configuration on this repository demo @pavdev64 ?
I tested that. The accessTokenPayload
is null
. It seems to be correct. The scope
is actually a property of tokens
. However the scope
is missing in the tokens
type.
export type Tokens = {
refreshToken: string;
idTokenPayload:any;
idToken:string;
accessTokenPayload:any;
accessToken:string;
expiresAt: number;
issuedAt: number;
};
so I had to retype it to any
. This works for me:
const tokens = OidcClient.get().tokens;
const scope = ((tokens as any)?.scope ?? '').split(' ');
const expiresAt = tokens?.expiresAt ?? undefined;
The scope
is present here.
I'd like to read
scope
value fromaccess token
and value ofexpiresAt
.First I tried to get
accessTokenPayload
usinguseOidcAccessToken()
like thisbut
accessTokenPayload
wasundefined
all the time whileaccessToken
had a value.With version 5.x I used
This worked, until version 6.x where
Oidc.get()
started to throw an exception. And it isn't mentioned the in breaking changes.I changed code to use OidcClient.get() instead
but still wondering if this is a correct way if we have hooks and actually why
useOidcAccessToken()
returnsaccessTokenPayload
withundefined
value.Is this a proper way how to do that?