Процесс застрял в URL обратного вызова при входе в систему auth0 - PullRequest
0 голосов
/ 14 апреля 2020

Я работаю над проектом React и интегрирую с ним auth0. Я выполнил все шаги, но он застрял в одной точке. Когда я собираюсь войти в систему с помощью auth0, используя учетную запись Gmail, он зависает на URL-адресе обратного вызова, и процесс останавливается handleAuthentication Метод не вызывается после URL-адреса обратного вызова. как я могу решить эту проблему ??

export default class Auth {
  auth0 = new auth0.WebAuth({
    domain: AUTH_CONFIG.domain,
    clientID: AUTH_CONFIG.clientId,
    redirectUri: 'http://localhost:3000/callback',
    audience: `https://${AUTH_CONFIG.domain}/userinfo`,
    responseType: 'token id_token',
    scope: 'openid'
  });

  constructor() {
    console.log('process.env.NODE_ENV',process.env.NODE_ENV)
    this.login = this.login.bind(this);
    this.logout = this.logout.bind(this);
    this.handleAuthentication = this.handleAuthentication.bind(this);
    this.isAuthenticated = this.isAuthenticated.bind(this);
  }

  login() {
    this.auth0.authorize();
    console.log('login done',store)
  }

  handleAuthentication() {
    console.log('asdfasfasf')
    this.auth0.parseHash((err, authResult) => {
      console.log('authResult.accessToken',authResult.accessToken)
      if (authResult && authResult.accessToken && authResult.idToken) {
        this.setSession(authResult);
        localStorage.setItem("user_id", "user-id");
        let store1 = store();
        store1.dispatch({ type: 'LOGIN_USER_SUCCESS', payload: authResult })
        window.location.replace('/')
      } else if (err) {
        console.log(err);
        alert(`Error: ${err.error}. Check the console for further details.`);
      }
    });
  }
}
...