-
Notifications
You must be signed in to change notification settings - Fork 442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
authorize() returns error 'Data intent is null' on Android #494
Comments
@KristineTrona did you find a fix to this |
@thilinawarnakula no, but I think it happens only on Android 11.0.0 (R), which has not been released to the public yet. |
@KristineTrona Hi Kristine, |
Hi, no, unfortunately I did not. |
Not sure if it will help others, |
I resolved this by adding the link prefix into the build.gradle file
e.g. If the redirect URL is |
Thank you for posting your solution @Shpadoinkle and @harunsmrkovic ! @KristineTrona Is this still an issue for you? I can't reproduce this on my emulator. This is the Example app with the Identity Server 4 configuration running on Pixel 2 with API 30. |
I am facing this same issue. |
I have the same issue and I tried all solutions in this thread, but I have not success. |
I am also facing the same issue did anyone gets anything. |
i am facing same issue |
From our production logs I see that some of our customers are getting this error, but I'm having a hard time reproducing the error. Does anyone have an "recipe" how to reproduce this error? I have tried to use these steps to reproduce it, but no luck #130 (comment) (Our app is using android:launchMode="singleInstance" instead of android:launchMode="singleTask", not sure if this has anything to do with this error) |
Hello @yberstad , the problem here is that, react-native-app-auth is not getting data from redirectUri. this is caused because of wrong configuration in intents.
basically, rn-app-auth gets data from // in build.gradle
defaultConfig{
...
manifestPlaceholders = [
appAuthRedirectScheme: 'your.deeplink.scheme.for.oauth'
]
} |
@AlkanV thank you so much for your very quick response, much appreciated! This is our current config:
/app/build.gradle:
And here is our current intent-filter's in AndroidManifest.xml:
Should I change it to this?
Just a clarification, we are only getting "Data intent is null" for some our Android users. It is working for the majority of our users. |
@yberstad did you find why it happens only to some users? |
@netanelh sorry, did not see your post before now. No, we have not figured this out yet. I have been able to reproduce the error (but not in a way I think the user does it):
I suspect that this is due to that we get a new instance of the app (using android:launchMode="singleInstance") and that the original intent is lost? If i look in node_modules/react-native-app-auth/android/src/main/java/com/rnappauth/RNAppAuthModule.java I see this code: The new intent is not "saved", but I do not know if this has anything to do with? Again, I do not think this is what the users experiencing this error is actually doing. If anyone have some new insights on this issue, it would be much appreciated! |
Any possible solution or workaround? @yberstad |
@DanielSchwartz89, not to my knowledge unfortunately. |
We have exactly the same issue in our project. @yberstad your reproduction steps are correct. To trigger "Data intent is null" error, the user must:
To avoid the issue, the user, during step 4, must use Recent apps/Overview button/gesture to navigate back to the app. For some reason, there is a difference in app-auth behavior depending on the user opening the app through the Home screen or Recent apps. One case always fails, the other succeeds. We suspect it is due to onResume() method triggering finish() in AuthorizationManagementActivity.java of AppAuth-Android. The issue is quite critical since in our case we need to use third-party banking apps to authenticate, so the users have to switch between apps. At the moment we have to manually instruct the users to use "Recent apps" instead of the home button, but that is not a good solution. |
The fix seems to be to change android:launchMode to "singleTop" in AndroidManifest.xml |
@Aleksefo, thank you so much for your info, very helpful! I was initially sceptic to change the android:launchMode, because I was not sure what implications it could have. But after trying to grasp the concept, I cannot see that would have any implications to change it (especially since we only have one activity in our RN application). I watched this series regarding the concept of lauchMode, https://www.youtube.com/watch?v=gRub-Pm_A0Q&t=36s, which was very helpful. |
@yberstad I've noticed some issues with this approach though: We also have a bank which prompts a user for extra input after the authentication. So overall I think it's a big win, since it doesn't affect successful logins, but fixes previously unsuccessful login almost without issues. |
@Aleksefo, thanks for a nice summary of various use cases. I'll bring that with me while testing our app 😄 |
@yberstad Sure, let me know if you'll find any extra issues. I think the next step would be to modify either react-native-app-auth or app-auth-android to disable onResume() methods that break the authentication and then apply a custom patch to get rid of the issue for good. |
@Aleksefo, I'll definitely get back to you if I find some issues regarding this! Again, thanks for letting me know of your findings! |
The issue is not related to Auth library, but android in general: https://issuetracker.google.com/issues/36907463 AndroidManifest.xml: MainActivity.java
The fix works in most of the cases except when the app is opened from an unusual source (react-native start, Google play, etc.). In that case, using home screen icon to return to the app will cause extra activity on top of the stack which cannot be removed using something like React Navigation, for example. Somewhere where you have login button:
|
It seems this ticket is diverging into different issues. The issue I'm referring to is the The problem I experienced was due to having deeplink integration already in place, using reactnavigation. You won't see this issue if you have not defined other intent-filters for the same auth scheme. Based on the reactnavigation instructions, I have the following set in my <activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize">
<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:scheme="com.myapp" />
</intent-filter>
</activity> And for android {
defaultConfig {
manifestPlaceholders = [
appAuthRedirectScheme: 'com.myapp'
]
}
} Note that adding the above effectively is the same as explicitly adding a new activity & intent filter like so: <activity
android:name="net.openid.appauth.RedirectUriReceiverActivity"
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:scheme="com.myapp"/>
</intent-filter>
</activity> So now we have two activities handling the same scheme. The result of this is that after logging in, I'm presented with an "Open With" prompt that shows my app twice. I assume because there are now effectively two If I select the app that's handling the To "fix" this, I followed @AlkanV's advice and used a different scheme for the authentication redirect url, set in the build.gradle: android {
defaultConfig {
manifestPlaceholders = [
appAuthRedirectScheme: 'com.myapp.auth'
]
}
} I then updated my redirect url to reflect the auth redirect scheme. After logging in, everything works. I don't get the "open with" prompt and I don't get the auth error. I don't like that the app handles two different deeplinking schemes, but I'm not sure if this is a problem or not. I will create a new ticket asking the library authors to update the example to include reactnavigation. Issue here: #611 |
This is still issue for me and problem is that its only happending on some android devices! |
@anisimov74 does the |
@badsyntax yes it is. It's |
@badsyntax and I see that in logs
|
Can you try without the landing.url host? So remove |
@badsyntax tried without |
I'm out of ideas. IMO it would be useful if this repo has a reactnavigation example that people can refer to. |
@badsyntax thank you for helping me! Will try more variants. |
I figured out the cause of the problem. There is a In Manifest.xml |
Incase you're using firebase deep links or your deep link is more like
Note: In the case of firebase, your You don't need to specify I no longer have the However, I now have a |
1
2 3
|
Closing this due to subject drift - sounds like a configuration issue. Creating redundant intent handlers by using both the manifest and manifestPlaceholders in build.gradle. |
Any update on this ? I am still facing same issue. I have applied all above changes but still facing same issue can some one help |
Same issue. Any updates? |
Same issue, double checked configuration. Has anyone figured out how to fix this? |
I had this issue recently and it turns out I was using characters on my scheme that are not allowed, such as ' / '. Fount some useful information about this on this Flutter rep: |
I have this issue as well |
I have this issued as well |
1 similar comment
I have this issued as well |
can we add multiple appAuthRedirectScheme to manifestplaceholder @harunsmrkovic ? |
I tried all solutions but getting same issue "Data intent is null". |
I also tried all of the solutions above and still I have the same issue. |
i resolved this by following steps:--
Add to application tag :
Remove from main activity:
|
i am also facing issue of data intent but i solve just by changing |
@badsyntax were you able to get the Authentication to return the access tokens currently the redirect link pops up for Android env but does not return back to the app. However, it does show in the AD sign-in logs that a user signed in and it was successful. not exactly sure what is going wrong |
Anyone found out a workaround? Tried all of the solutions above and still I have the "Data intent is null" error. React native v0.63.2 AndroidManifest.xml:
|
Issue
Every time I call
authorize()
method I getError: Data intent is null
, whenever running on an Android emulator with 'R' operating system. Any idea what could be causing this error and how to fix it?In android/app/builde.gradle
AndroidManifest.xml
Fails on all 3 of these, but works fine on 'Q' or 'Pie' operating systems:
Environment
The text was updated successfully, but these errors were encountered: