Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can Google detect a request is from a WebView?

Tags:

Google announced that they "will no longer allow OAuth requests to Google in embedded browsers known as 'web-views'".

In Android, requests from WebViews get a header HTTP_X_REQUESTED_WITH which is set to the package name of the application. Although this can be overridden, so it would be possible to hide to the server that we are making request using a WebView. I don't know any other default way to make this.

Is there a way to detect, server side ― and no matter what the client does, that a request is from a Android WebView. How is this done by Google?

like image 479
oldergod Avatar asked Jan 23 '17 08:01

oldergod


People also ask

How does Android detect WebView?

It appears they were quite sneaky in hiding this, but you can check if the window has a property named "Android " (with a space at the end). This appears to be true only when being used as a WebView inside an app, and not in Chrome on the same device.

Does Chrome use WebView?

No, Chrome for Android is separate from WebView. They're both based on the same code, including a common JavaScript engine and rendering engine.

Does Google Play accept WebView app?

You can use any of them as per your usability. Have you read the reviews of Android System Webview on Google Play Store? Yes, the reviews are quite funny and sarcastic.


1 Answers

Not answering your question directly (sorry), but regarding the deprecation of WebView for OAuth that you referenced: even if you find a way to avoid the WebView being detected during an OAuth flow, doing so may run contrary the Google API Services: User Data Policy, in particular the section "Do not mislead Google about an application's operating environment". So I wouldn't recommend that.

Typically using Custom Tabs for OAuth (such as via AppAuth for Android) results in a better user experiance anyway, as the user will likely already be signed-in to Google allowing them to review your request without needing to sign-in again. It's also more a more secure experiance. That's the goal of the migration – a more secure, more usable OAuth experiance for end-users :-)

like image 59
William Denniss Avatar answered Sep 26 '22 02:09

William Denniss