Auth0 Home Blog Docs

Callback Failing in React Native with Twitter Login

twitter

#1

I am trying to get the 00-login sample app (React Native with Twitter login) to work. The login is succeeding on the Twitter side (I know this mainly because I am getting an email from Twitter warning me about a login from a new device).

I am running the app on an Android emulator with ‘react-native run-android’.

The callback I have set (per the sample app instructions) in Auth0 application settings is:

com.auth0sample://myTenantName.auth0.com/android/com.auth0sample/callback

My callback URL setting in the Twitter application is:

https://myTenantName.auth0.com/login/callback

My AndroidManifest.xml has:

The emulator shows this error page after entering credentials in Twitter’s login page:

55%20PM

The “Try It” button on Connections/Social in the Auth0 dashboard says “It Works”.

Any suggestions?


#3

Hey @mark100 !

At first glance everything seems fine. Can you let me know what version of React Native do you use? The error reads like it’s not configured correctly on the android side. Thanks in advance for providing more info!


#4

It might be also because of the browser you use, which is not correctly redirecting URL with custom scheme. This should work fine on most common browsers. Can you also try on a different browser/Android phone?

Thanks a lot!


#5

Konrad,

I am using react-native 0.47.2 in this project.

I had tried it on a couple different emulators with the same result.

I tried it again on a real device and used the Chrome browser. This time login was successful (as before) but instead of callback failing it never left the “Redirecting you back …” page. I guess that’s an “improvement” but this would require the user to manually close the browser.
Thanks,

Mark


#6

Is your package name com.auth0sample in the manifest file? Are you using the same package name in the intent-filter configuration?

It seems as if the callback URL (com.auth0sample://…) is not being recognized by the system.


#7

I put the info from manifest in the original post but it didn’t show up.

I will try again:

 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.auth0sample"

 <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
  <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="pokervane.auth0.com"
          android:pathPrefix="/android/${applicationId}/callback"
          android:scheme="{applicationId}" />
    </intent-filter>

applicationId is “com.auth0sample”.


#8

The android:scheme is missing the dollar sign. It should be:

<data
[...]
android:scheme="${applicationId}" />

If that doesn’t work (try it first), can you try replacing the two ${applicationId} occurrences with com.auth0sample? Sorry I’m asking you to try things blindly, but I’m having troubles with my Java VM at the moment so I can’t reproduce.

So that you get this:

<intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
  <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="pokervane.auth0.com"
          android:pathPrefix="/android/com.auth0sample/callback"
          android:scheme="com.auth0sample" />
    </intent-filter>

#9

Hey @mark100!

Have you had time to try what Nicolas suggested and solve your problem?

Let us know if that worked!


#10

Konrad,

I have not had a chance to get back to it yet. Of course I will let you know the status when I do.

Thanks,

Mark


#11

The missing $ appears to have been the problem.

Thanks for your help!


#12

Perfect! Glad that you made it!