react-native-oauth
react-native-oauth copied to clipboard
Android 403: Error: Disallowed Useragent
When trying to run this on android, it seems that google has now disallowed web views, is there any other way to get this library to work on android?
I started a project from scratch and I'm having the same issue.
"react-native": "0.42.3", "react-native-oauth": "^2.1.16"
I'll check later today... see if I can't figure out what's happening
Any updates?
You can use this fork until the PR gets merged in https://github.com/timbielawski/react-native-oauth
I'm still having the same issue.
react-native: 0.42.0 react-native-oauth: 2.1.16
Same, even after updating changes that @timbielawski made.
react-native 45.1 react-native-oauth 2.1.16
The same:
react-native: 0.45.1, react-native-oauth: 2.1.16
The changes of @timbielawski works perfectly. Don't forget to clean the project after making those changes.
cd android
./gradlew clean
Any update on this issue?
@HarshankArastu Try this fork which might fix this bug. https://github.com/roshangm1/react-native-oauth
solved https://www.youtube.com/watch?v=vFSgIdtEl2k
@HarshankArastu Try this fork which might fix this bug. https://github.com/roshangm1/react-native-oauth
It solved the issue for me. When will this be merged?
@roshangm1 added the solution but its not merged yet. For the moment just modify the file in node_modules: node_modules/react-native-oauth/android/src/main/java/io/fullstack/oauth/OAuthManagerDialogFragment.java
:
...
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setDomStorageEnabled(true);
// add this line (112)
mWebView.getSettings().setUserAgentString("Mozilla/5.0 (Linux; Android 4.1.1; Galaxy Nexus Build/JRO03C) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19");
...
@krisidmisso your solution worked for me. Looks like it'll be merged into the repo soon
@roshangm1 added the solution but its not merged yet. For the moment just modify the file in node_modules:
node_modules/react-native-oauth/android/src/main/java/io/fullstack/oauth/OAuthManagerDialogFragment.java
:... mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setDomStorageEnabled(true); // add this line (112) mWebView.getSettings().setUserAgentString("Mozilla/5.0 (Linux; Android 4.1.1; Galaxy Nexus Build/JRO03C) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19"); ...
The above fix actually generates another issue. If you get a notification from google it will say that you have logged in from a Nexus device due to the user agent string Galaxy Nexus...
Hopefully there will be another fix
@roshangm1 added the solution but its not merged yet. For the moment just modify the file in node_modules:
node_modules/react-native-oauth/android/src/main/java/io/fullstack/oauth/OAuthManagerDialogFragment.java
:... mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setDomStorageEnabled(true); // add this line (112) mWebView.getSettings().setUserAgentString("Mozilla/5.0 (Linux; Android 4.1.1; Galaxy Nexus Build/JRO03C) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19"); ...
The above fix actually generates another issue. If you get a notification from google it will say that you have logged in from a Nexus device due to the user agent string
Galaxy Nexus...
Hopefully there will be another fix
A quick and dirty fix for you is just simply remove the Galaxy Nexus...
from the User-Agent string you set
or you can use mWebView.getSettings().setUserAgentString(mWebView.getSettings().getUserAgentString())
to get the real UserAgent and set it back to the webview
update on 12 Apr 2021:
you can remove wv
from the UserAgent
mWebView.getSettings().setUserAgentString(mWebView.getSettings().getUserAgentString().replace("; wv", ""));
Ref: https://developers.googleblog.com/2016/08/modernizing-oauth-interactions-in-native-apps.html
P.S. I have open the PR for this issue, however this library seems no longer supported by the original author, you may consider using other OAuth RN library.
Simple add userAgent={"chrome"}
It's works for me 🤘
I encountered this issue in Android (and not react). I first started with the solution
web_view.settings.userAgentString = "Mozilla/5.0 (Linux; Android 4.1.1; Galaxy Nexus Build/JRO03C) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19"
it worked. However, if the user is not logged in, Google asks the user to login and when they ask the user to verify the login, sometimes on an already logged in device and they report incorrect device details.
Eg: On using the above example I was said I tried logging in on an Android 4 device, even when I was on an Android 9 device. This could be confusing to users.
So I tried seeing what's the default value in web_view.settings.userAgentString
and found the value to be
Mozilla/5.0 (Linux; Android 9; vivo 1904 Build/PPR1.180610.011; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/89.0.4389.90 Mobile Safari/537.36
I realised the problem is wv
in the above string, so I just removed that and it worked fine.
My end code looked something like this
web_view.settings.userAgentString = settings.userAgentString.removeAll("; wv")