react-native-auth0 icon indicating copy to clipboard operation
react-native-auth0 copied to clipboard

on the Android side, How to open the login page normally when the application package name contains uppercase letters

Open cx5168 opened this issue 1 year ago • 6 comments

Checklist

Description

The application package name contains uppercase letters, and callbackUrl has been set to lowercase letters. Setting customScheme cannot open it properly.

I hope to not change the application package name and be able to use auth0 normally.

Please provide some solutions, thank you.

Reproduction

  1. In the auth0 console, callbackUrl has been set to lowercase letters (e.x. com.testapp.auth0://auth0.com/android/com.testapp/callback)
  2. The package name in the application contains uppercase letters (e.x. com.testApp)
  3. Accessing webAuth.authorize, customScheme has been set (e.x. customScheme: com.testApp.auth0)
  4. The app/build.gradle has added the manifestPlaceholders setting (e.x. manifestPlaceholders=[auth0Domain: "auth0.com", auth0Scheme: "${applicationId}.auth0"]). The applicationId is com.testApp.
  5. Android: launchMode="singleTask" has been removed from AndroidManifest.xml

Additional context

No response

react-native-auth0 version

3.1.0

React Native version

0.73.4

Expo version

No response

Platform

Android

Platform version(s)

34

cx5168 avatar Mar 08 '24 02:03 cx5168

Solved it. Please refer to No.1:https://github.com/auth0/react-native-auth0/blob/master/FAQ.md

cx5168 avatar Mar 11 '24 02:03 cx5168

But there is another issue. After the first successful login, the same email will be logged in again and the login page will be automatically skipped.

Please help

cx5168 avatar Mar 11 '24 02:03 cx5168

But there is another issue. After the first successful login, the same email will be logged in again and the login page will be automatically skipped.

Please help

cx5168 avatar Mar 11 '24 08:03 cx5168

@cx5168 Have you solved the issue, and could you provide the details how you solved in in the first comment? I read the first point but it still doesn't work for me.

kulaszewicz avatar Apr 05 '24 14:04 kulaszewicz

@kulaszewicz

  1. On the management side of auth0, set the value of callbackURL to lowercase letters
  2. Delete the manifestPlaceholders setting for app/build.gradle
  3. In AndroidManifest.xml, add the following line <activity android:name="com.auth0.android.provider.RedirectActivity" android:exported="true" tools:node="replace"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:host="[your auth0 host]" android:pathPrefix="/android/[Lowercase applicationId. ex: aaa.com]/callback" android:scheme="[Lowercase applicationId. ex: aaa.com].auth0" /> </intent-filter> </activity>
  4. delete the build folder for app
  5. rebuild

cx5168 avatar Apr 10 '24 07:04 cx5168

I found that version 3.2.1 simply does not work with Expo and custom scheme. After updating to the v4 beta, everything works as expected!

Hope this helps someone not waste the hours I did not just trying the latest version....

GriffinMeyer avatar Aug 22 '24 18:08 GriffinMeyer

@GriffinMeyer sorry you had to spend time on this! thanks for confirming that this issue is resolved on v4 beta.

@cx5168 could we close this issue now?

brth31 avatar Nov 15 '24 05:11 brth31

Upgrading to v4.0.0 should resolve the issue with custom schemes and different casing between your app package name and callback URL.

If you continue to face problems after updating, please reopen this issue with any additional details. Thanks.

arpit-jn avatar Jan 08 '25 15:01 arpit-jn

I just hit this issue with 5.0.1 on Expo. I tried to set the customScheme to the lowercase variant which fixed the callbackUrl, but that didn't fix the auto-generated intent-filter in the AndroidManifest file. The pathPrefix still contains the uppercase package name which causes that after a successful authentication the callbackUrl never opens up the app. can we reopen this issue @arpit-jn?

adamivancza avatar Oct 09 '25 16:10 adamivancza

I've taken a quick look at the source as well and I think the issue can be fixed here: https://github.com/auth0/react-native-auth0/blob/92b3637023275bd59590cea96ecf886c47306bfb/src/plugin/withAuth0.ts#L104C23-L104C46 if we would lowercase the applicationId on this line, that would fix the intent-filter. Especially that you're already lowercasing the bundleId when generating the callbackUri: https://github.com/auth0/react-native-auth0/blob/92b3637023275bd59590cea96ecf886c47306bfb/src/platforms/native/adapters/NativeWebAuthProvider.ts#L128

lmk if you agree and I can spin-up a PR with this fix @arpit-jn

adamivancza avatar Oct 09 '25 21:10 adamivancza