I would like to be able to specify the scopes required when authenticating
I've tried using advanced options default scope but I can only seem to use this to remove scopes. I want to add the google calendar read-only scope
this.auth0Client = await createAuth0Client({
domain: options.domain,
client_id: options.clientId,
audience: options.audience,
redirect_uri: redirectUri,
advancedOptions: {
defaultScope: 'profile email https://www.googleapis.com/auth/calendar.readonly'
}
});
I know I could use incremental authorization and use getTokenSilently but I'd rather request them all upfront.
Thank you
I would like to be able to specify the scopes required when authenticating
Have you tried using scope on createAuth0Client (https://auth0.github.io/auth0-spa-js/interfaces/auth0clientoptions.html#scope) ?
createAuth0Client({ scope: 'https://www.googleapis.com/auth/calendar.readonly' })
Alternatively you can provide scope when calling loginWithRedirect (https://auth0.github.io/auth0-spa-js/interfaces/redirectloginoptions.html#scope) or loginWithPopup (https://auth0.github.io/auth0-spa-js/interfaces/popuploginoptions.html#scope):
loginWithRedirect({ scope: 'https://www.googleapis.com/auth/calendar.readonly' })
loginWithPopup({ scope: 'https://www.googleapis.com/auth/calendar.readonly' })
Does this help?
I've tried using advanced options default scope but I can only seem to use this to remove scopes.
I am not sure I understand what you mean with this.
I think what you are looking for would be to use connection_scope, as mentioned here : https://auth0.com/docs/connections/adding-scopes-for-an-external-idp#2-pass-scopes-to-authorize-endpoint which u can pass to loginWithRedirect as follows:
loginWithRedirect({ connection_scope: 'https://www.googleapis.com/auth/calendar.readonly' })
Thank you @frederikprijck, This worked
loginWithRedirect({ scope: 'https://www.googleapis.com/auth/calendar.readonly' })
loginWithPopup({ scope: 'https://www.googleapis.com/auth/calendar.readonly' })
I appreciate your help :)