Search code examples
androidreact-nativeoauthappauthandroid-app-links

Data intent is null in Android using universal links/applinks using react-native-app-auth


i am using react-native-app-auth for Authorization using okta.

I tried appSchemes and Applinks/universal links in both iOS and android. But android applinks giving me [Error: Data intent is null]. It is working fine with appScheme. Redirection to the application is working, but something going wrong while capturing the auth response. These are my configurations

AndroidManifest.xml

<intent-filter android:autoVerify="true">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="https"
          android:host="myDomain.com"
        />
      </intent-filter>

build.gradle:

manifestPlaceholders = [
     appAuthRedirectScheme: 'myAppScheme',
 ]

AuthConfig:

{
        issuer: "https://dev-xxxxxx.okta.com/oauth2/default",
        clientId: '${MyClientId}',
        clientSecret: '${MyClientSecret}',
        redirectUrl: "${myDomain.com}",
        scopes: ['openid', 'profile', 'email', 'offline_access'],
      };

I suspect that i am missing some configuration in the Android setup while capturing the response of authorize() method. But i am unable to figure it.

I am seeing soo many references, but all are pointing to appSchemes but my issue is with universal links/applinks


Solution

  • I fixed it by wrapping the intent-filter in seperate activity. This is not mentioned anywhere in the document as i see.

        <activity
            android:name="net.openid.appauth.RedirectUriReceiverActivity" 
            android:exported="true">
              <intent-filter android:autoVerify="true">
                    <action android:name="android.intent.action.VIEW" />
                    <category android:name="android.intent.category.DEFAULT" />
                    <category android:name="android.intent.category.BROWSABLE" />
                    <data
                        android:host="myDomain.com"
                        android:scheme="https" />
                </intent-filter>
          </activity>