react-nativeflaskwebviewokhttpuser-agent

React Native okhttp user agent


I have a React native application using a Webview for most of the UI. We've been facing some issues on out backend side where there are multiple revoke token errors. The backend is in Flask. We've added some logs and the only thing common for these error is that the user agent is 'okhttp' with some version number. The user agent is supposed to be the webview browser i.e chrome for android & safari for iOS (it is correct for normal cases).

I haven't been able to reproduce the issue myself but there are too many instances in production. What could be the possible reason of this user-agent (okhttp) being logged instead of the actual one? Any direction to fix the issue?

"react-native": "0.71.7", "react-native-webview": "12.1.0",

I'm using applicationNameForUserAgent={${Platform.OS`} in webview which show the respective OS as well for normal usage. I've logged both android & iOS but haven't seen a single instance of 'okhttp' on local.


Solution

  • The 'okhttp' agent is the default agent for Android in React Native projects. It was present due to some API calls being made on the RN side. I was able to reproduce and resolve the issue that was specific to Android later