Skip to content

Ability to provide Auth0Client to Auth0Provider #187

@Birkbjo

Description

@Birkbjo

Describe the problem you'd like to have solved

In some cases the auth-object is needed outside of react-components. Currently it's hard/hacky to bring the auth-client out from the react-context. Some use cases include getting the access token for use in thunks, redux-observables etc. I do not want to copy or replicate the auth-profile or it's token in a redux-store, but I want access to eg. getAccessTokenSilently() from imperative code elsewhere in the application, without passing the auth-object to every observable/thunk/side-effect.

Describe the ideal solution

Ability to provide an instantiated instance of Auth0Client (from auth0-spa-js) to the Auth0Provider, if this is present that client instance is used in the provider when calling the functions provided by the context.

For instance

// somewhere
const client = new Auth0Client({
  domain: '<AUTH0_DOMAIN>',
  client_id: '<AUTH0_CLIENT_ID>',
  redirect_uri: '<MY_CALLBACK_URL>'
});
export default client

// In component: 
import client from 'somewhere'

 <Auth0Provider client={client}>
      {children}
  </Auth0Provider>

Alternatives and current work-arounds

I would love to get input on workarounds for this, as I'm still exploring how to fix this without rewriting all the code to use hooks/ async code in components.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions