Reputation: 83
I've developed a react-native app which uses Auth0 to authenticate users.
I am getting a 403 disallowed_useragent
error when some users try to authenticate using Google from my react-native app, using webAuth. As I searched, this is related to the browser app installed in the user device.
I can reproduce this issue using an Android 11 emulator disabling the Chrome browser, so the OS uses the WebView Browser Tester. If I let Chrome browser enabled, everything works OK.
So my question is: Is there a way to check if the browser installed in the user device supports Google Auth? So I can tell the user to update/install his browser if necessary.
I am using the official SDK react-native-auth0 v2.9.0 and react-native v0.66.0
Upvotes: 4
Views: 4676
Reputation: 49
A work around consist of modifying the useragent definition used to request the authentication to goolgle api,
When using the mobile webview, the useragent may contain at the end of the browser version component string definition the string "wv"
abbreviation of W
ebV
iew, google is not allowing anymore for a security reason webview browser to perform an authentication on their platform.
the solution is to remove the string ; wv
from the useragent version definition string component, by a simple string replace operation : useragent.replace("; wv)", ")")
<WebView
source={{uri}}
style={{flex: 1}}
userAgent={
'Mozilla/5.0 (Linux; Android 12; Pixel a5 Build/SP1A.210812.016; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/114.0.5735.130 Mobile Safari/537.36'
}
/>
so, then instead of :
Mozilla/5.0 (Linux; Android 12; Pixel a5 Build/SP1A.210812.016; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/114.0.5735.130 Mobile Safari/537.36
use :
Mozilla/5.0 (Linux; Android 12; Pixel a5 Build/SP1A.210812.016) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/114.0.5735.130 Mobile Safari/537.36
best wishes.
Upvotes: 2