auth0 / auth0-cordova

Auth0 integration for Cordova apps
MIT License
49 stars 66 forks source link

Callback not fired in client.authorize() when connection parameter is passed #63

Closed thomasmarren closed 5 years ago

thomasmarren commented 6 years ago

I'm trying to open Google authentication directly from my Cordova app rather than going to the hosted login page and having the user click "Sign in with Google." I'm passing the connection parameter into the client.authorize() function like so:

    let auth0Config = {
      clientId: this.config.auth0.clientId,
      domain: this.config.auth0.domain,
      callbackURL: this.config.auth0.callbackURL,
      packageIdentifier: this.config.auth0.packageIdentifier
    }
    const client = new Auth0Cordova(auth0Config)
    const options = {
      scope: 'openid profile offline_access',
      audience: this.config.auth0.audience,
      connection:'google-oauth2',
    }
    client.authorize(options, (err, authResult) => {})

It is loading the Google OAuth page as expected however once the user authenticates, the callback is not fired. The url is being redirected back to the app, and I am passing it into Auth0Cordova.onRedirectUri()

The same process works as expected without the connection parameter so I'm wondering if this library does not support a connection parameter? I know this is possible with the Auth0-js library.

Thank you

EDIT: It only occurs when I've previously logged in with Google and it remembers my login. The redirect seems to be happening too early. If it is my first time authenticating with Google it works as expected.

darkyen commented 6 years ago

Hi Thomas, apologies for the delay, can you try the latest version? I'm trying to reproduce this atm.

bocodigital commented 6 years ago

I can confirm same issue using google. Call back never gets fired and no error is thrown and I am using 0.3.0, also for me it never fires the callback, first login or otherwise. First time trying from Google page it dies here client.oauthToken({ code_verifier: verifier, grantType: 'authorization_code', redirectUri: redirectUri, code: code }, function (exchangeError, exchangeResult) { if (exchangeError) { return callback(exchangeError); } return callback(null, exchangeResult); });

Update: hopefully saving people time, if you don't set your Client in the Dashboard to either SPA or Native, auth0-js tries to call the token endpoint and silently fails because it requires client_secret unless set to SPA or Native.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you have not received a response for our team (apologies for the delay) and this is still a blocker, please reply with additional information or just a ping. Thank you for your contribution! 🙇‍♂️