You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Beta v4 integration looks great! I helped a Convex customer set it up with Convex so we needed an ID token, the one the useUser() claims are from. I added the second argument of async beforeSessionSaved(session, idToken) to the object returned from that callback to make it available, then used useUser to get it. This solution was indirect so something more obvious could be useful.
Describe the ideal solution
If getAccessToken() took an argument for also returning the ID token or there were a new getIdentityToken() that'd be convenient.
Alternatives and current workarounds
Currently I'm recommending using getAccessToken for the side effect of updating the token, which works because fetchAccessToken is rerun when its identity changes.
const{ user, isLoading }=useUser();constidToken=user?.idToken;constfetchAccessToken=useCallback(async()=>{try{// maybe the side effect of getAccessToken// will include updating the idToken?void(awaitgetAccessToken());returnidToken;}catch{returnnull;}},[getAccessToken,idToken]);
and adding the idToken to the user object.
async beforeSessionSaved(session, idToken) {
return {
// Spread existing session properties to preserve original data
...session,
user: {
// Spread existing user properties
...session.user,
// Raw identity token
idToken,
},
};
},
Additional context
No response
The text was updated successfully, but these errors were encountered:
Thanks for the feedback @thomasballinger! Initially we wanted to avoid storing the ID token on the session by default to avoid exceeding the browsers' cookie size limits — instead we only store a subset of the claims which can be modified using the beforeSessionSaved hook as you shared.
We'll look into offering a simpler (opt-in) way to store and retrieve the access token.
Checklist
Describe the problem you'd like to have solved
Beta v4 integration looks great! I helped a Convex customer set it up with Convex so we needed an ID token, the one the useUser() claims are from. I added the second argument of
async beforeSessionSaved(session, idToken)
to the object returned from that callback to make it available, then used useUser to get it. This solution was indirect so something more obvious could be useful.Describe the ideal solution
If
getAccessToken()
took an argument for also returning the ID token or there were a newgetIdentityToken()
that'd be convenient.Alternatives and current workarounds
Currently I'm recommending using getAccessToken for the side effect of updating the token, which works because fetchAccessToken is rerun when its identity changes.
and adding the idToken to the user object.
Additional context
No response
The text was updated successfully, but these errors were encountered: