react-routers hashBrowser is not working with Auth0 callbacks

Created on 28 Dec 2015  路  5Comments  路  Source: ReactTraining/react-router

When auth0 is using the provided callback it usually has the format https://webiste.com/#access_token=abc

react-router interpret that as https://webiste.com/#/access_token=abc and complains that there is no route access_token.

Is there any way around that?
I know there is browserHistory, but that seems to require a massive rewrite of my backend.

Most helpful comment

I'm having the same issue. Could someone please kindly confirm how to integrate auth0 with RR 2.4x?

All 5 comments

@Moezalez
I had a same problem but you can work around by parsing hash and edit/clear hash before render router dom.

example code below

const lock = new Auth0Lock('client_key','domain');
var idToken = localStorage.getItem('userToken');
const authHash = lock.parseHash(window.location.hash);
if (authHash) {
  if (authHash.id_token) {
    idToken = authHash.id_token
    localStorage.setItem('userToken', authHash.id_token);
    location.href = '/#/';
  }
  if (authHash.error) {
    console.log("Error signing in", authHash);
  }
}

ReactDOM.render(
  <Provider store={store}>
    <Router history={history} routes={routes} />
  </Provider>
  , document.getElementById('root')
);

Since the release of Auth0-lock v10 this workaround seems not to work anymore?

I'm having the same issue. Could someone please kindly confirm how to integrate auth0 with RR 2.4x?

I'm experiencing the same warning. Will this issue be addressed again? The example from Auth0 is using react-router: https://auth0.com/docs/quickstart/spa/react/01-login

Was this page helpful?
0 / 5 - 0 ratings