Skip to content

Instantly share code, notes, and snippets.

@Tanver-Hasan
Created March 15, 2022 12:42
Show Gist options
  • Save Tanver-Hasan/7b6623a78833f450814b9e770c787b2e to your computer and use it in GitHub Desktop.
Save Tanver-Hasan/7b6623a78833f450814b9e770c787b2e to your computer and use it in GitHub Desktop.
Pass custom parameter in /authorize endpoint

For auth0-spa-js and auth0-react - any extra options you pass to the SDK will be sent as custom params to the authorization server when redirecting to /authorize endpoint, eg

auth0-spa-js SDK

const auth0 = await createAuth0Client({
  domain: '<AUTH0_DOMAIN>',
  client_id: '<AUTH0_CLIENT_ID>',
  redirect_uri: '<MY_CALLBACK_URL>',
  // Pass custom parameters to login & silent auth
  customParam="foo"
});

// Or just for silent auth

auth0.getTokenSilently({ customParam: "foo" })

auth0-react SDK

ReactDOM.render(
    <Auth0Provider
      domain="YOUR_AUTH0_DOMAIN"
      clientId="YOUR_AUTH0_CLIENT_ID"
      redirectUri={window.location.origin}
      // Pass custom parameters to login & silent auth
      customParam="foo"
    >
      <App />
    </Auth0Provider>,
    document.getElementById('root')
);

// Or just for silent auth

getAccessTokenSilently({ customParam: "foo" })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment