Change the grant_type using React SDK

Hello.
I’m currently in the process of migrating from the auth0-js SDK to auth0/auth0-react SDK.

I’ve wrapped my app in an Auth0Provider component with the following props:

domain={'...'}
audience={'https://...'}
clientId={'...'}
redirectUri={window.location.origin}
scope={'openid email profile <scopes...>'}
useRefreshTokens={true}

When i call

token = await getAccessTokenSilently({
      audience: 'https://...,
      scope: '<...>'
    });

I get the following error message in the developer tools:

Silent callback error: error=unauthorized_client&error_description=Grant type ‘authorization_code’ not allowed for the client.

The auth0-js settings before the migration to react SDK were:

// ***PREVIOUS SETTINGS***
const auth0Client = new auth0.WebAuth({
  domain: '...',
  audience: 'h...',
  clientID: '...', 
  redirectUri: window.location.origin,
  responseType: 'token id_token',
  scope: 'openid email profile <...>'
});

Since I can’t pass to Auth0Provider component the responseType property like i previously did, how can I set the grant type to token id_token?

Hi @yuv-c !

This should be able to be resolved by allowing the Authorization Code grant type in the relevant Application’s settings. I assume you are using a SPA app configured in Auth0?

Out of curiosity, is there a particular reason you are looking to use the implicit grant type with the React SDK? It’s recommended to use Authorization Code (+ PKCE) whenever possible as outlined in the following blog post:

Let us know you thoughts and we can go from there!

Thank you @tyf.
Though this is doesn’t directly answer what I asked (“how can I set the grant type to token id_token?”)
We are currently using implicit grant type in our existing app for a while now.
I will look into using authorization code with PKCE instead of implicit.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.