auth0-samples / auth0-ionic-samples

Other
32 stars 49 forks source link

Andorid React not authenticated after returning to app #698

Open himynameistim opened 2 months ago

himynameistim commented 2 months ago

Checklist

Description

I have downloaded the sample for React and tested using an Android device.

Clicking login correctly loads the Auth0 login page in a browser and after entering credentials the user is taken back to the app, however they're still not authenticated.

Clicking login a second time redirects to auth0 which immediately redirects back to the app, but the app still shows the user as unauthenticated.

Reproduction

  1. Download sample with auth0 account logged in
  2. Add allowed urls to auth0 application settings
  3. Complete npm install etc instructions
  4. Open app in Android Studio and generate app package
  5. Deploy to device (I'm using real devices via lambda test)
  6. Login

Additional context

No response

Sample

React

Platform

Android

Platform version(s)

13

himynameistim commented 1 month ago

Figured this out. The instructions specify to set Allowed origins and by default there is a property named Allowed web origins in the Auth0 Application settings.

However in addition to this Cross-Origin Authentication needs to be switched on and the following domains added to Allowed Origins (CORS)

capacitor://localhost, http://localhost, http://localhost:3000/, https://localhost

If you don't do this the following error will appear in the logs.

Origin https://localhost is not allowed. Behavior used for check: LEGACY

The documentation could be updated to make this clearer.