Hey, fairly new to Auth0 and am using it for a client project. We’re trying to implement account linking, and I’m working on a client-side implementation using Auth0.js. I’m getting my management access token like so:
this.auth.checkSession(
{
audience: `https://YOUR_DOMAIN/api/v2/`,
scope: "read:current_user"
},
(err: any, result: any) => {
const management = new auth0.Management({
domain: process.env.VUE_APP_AUTH0_DOMAIN,
accessToken: result.accessToken
})
...
}
)
I gather this is the point where I need to call linkUser
, but from which account should I obtain the management access token? I.e. do I:
- Log into the primary account.
- Get the management access token.
- Cache the current ID and access tokens in local storage.
- Reauthorize with the new connection.
- In my callback handler, check for the existence of a previous ID/access token. If they exist, request the management token and link the previous account ID with the current ID token.
Or:
- Log into the primary account.
- Cache the current ID and access tokens in local storage.
- Reauthorize with the new connection.
- Get the management access token.
- In my callback handler, check for the existence of a previous ID/access token. If they exist, request the management token and link the previous account ID.
I.e. Assuming I have the process correct, do I get the access token I use for the link in step 2 or 4?
Thanks.