react-native-auth0: Auth module response handler expects `.json` keys presence when it is not returned in successful request

Description

Auth module response handler expects .json key that does not exist on status 200 response.

Reproduction

const makeAuth0Client = () => (new Auth0({
  domain: REDACTED,
  clientId: REDACTED,
}));

try {
  const { idToken, refreshToken } = await makeAuth0Client().webAuth.authorize({
    prompt: 'login',
    scope: 'openid offline_access',
  });
} catch (e) {
  console.log(e);
}

see the following error

a0.response.invalid

Inspecting what src/auth/index.js#responseHandler receives, we see no .json key present, hence the throw. {status: 200, ok: true, headers: REDACTED, text: "OK"}

Environment

react-native-auth0: 2.3.1 iOS: 11.0 react-native: 0.62.2 osx: 10.14.6

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 24 (10 by maintainers)

Most upvoted comments

@lbalmaceda for me the issue was happening because of this; react-native issue https://github.com/facebook/react-native/issues/27250 after adding the updated implementation of okhttp, all social logins works great

Hello, I am having almost the same issue on 2.7.0.

Same exact process, but instead of username/password, we are using social login: connection: 'google-oauth2',.

All signs point toward a successful login (webauth closes, logs show successful auth and exchange, etc.) but the error is thrown due to no json. Comparing the social login user account to a username and password user account (/authorize, so no issues there) in the auth0 dashboard, there is nothing to indicate that there are any differences or issues with the social login user account.

Edit: I removed the connection to attempt to login with username and password through webauth (using the account that previously worked with /authorize), and still receive the error, so for some reason, no json property is coming back from the webauth (perhaps due to the deep link?), or maybe some kind of configuration issue.

I’m still a bit confused. The developer on your team has tested this using the same code with the same client_id and domain as you but using a different username + password, and they are being able to log in and you are not. Did I get that right?

correct.

it’ll be a while till we can give the network logs as we’re midway through a big upgrade and we’ve already removed this dependency. FWIW, the react-native-debugger network logs were not informative as the login flow redirects us to a webview (where the auth0 response is captured) before directing back to the app. Safari does allow a bridge mode to inspect the requests of a simulated device in that webview, but it won’t record those requests (dang).

The summary pasted above is the best detail we can give as to the shape of the response at this time! 🙇

Could you please try If this still happens with the version immediately prior to that? That would be 2.3.0

hmmm, we rebuilt on 2.3.0 and see the same error