hypothesis / hypothesis/h

OAuth login to client not working in Android WebView (and iOS too?)

Open
#4,675 17 comments 1 reaction 0 assignees View on GitHub
API bug
Dominant language
Python
Stars
3.2k
Forks
459
Avg merge
27d 1h
Merged PRs (30d)
1

Description

When I use Android [Webview ](https://developer.android.com/reference/android/webkit/WebView.html) to browse inside an android app and load the hypothesis bookmarklet, it will succeed in loading the side bar and showing the public annotations. However, I have to login to do my annotations.

When I click on login, and because Webview cannot open a new tab or window, it will open the login page in the same "tab" or Webview "window". After I enter my credentials, it will redirect me to a blank page and will stuck there.

I tried to investigate what is happening when it redirects to the blank page.
Opened: `http://google.com`
then loaded the bookmarklet:
`javascript:(function(){window.hypothesisConfig=function(){return{showHighlights:true,appType:'bookmarklet'};};var d=document,s=d.createElement('script');s.setAttribute('src','https://hypothes.is/embed.js');d.body.appendChild(s)})();`

and login with my hypothesis credentials.

The title of the blank webpage after login is:
**Authorization completed**

And the url:
https://hypothes.is/oauth/authorize?client_id=631206c8-7792-11e7-90b3-872e79925778&origin=https%3A%2F%2Fhypothes.is&response_mode=web_message&response_type=code&state=d293c1b2c1829b4f

It seems it fails to go back to the original url (here: http://google.com).

In Android Chrome browser and other browsers which are all successfully working with the bookmarklet, what happens is that when I click on login, a new tab will popup and when I finish login this window will close and return to the former window with the bookmarklet active.

-->
**### Steps to reproduce**
1. Android Webview in an Android app (Android 6.0.1, SM-N9005)
2. Load a web page
3. Load the hypothesis bookmarklet
4. Login using hypothesis credential
5. Redirects to a blank page

**### Expected behaviour**
It should redirect to the original website that I want to annotate with bookmarklet active and logged in

### Actual behaviour
Redirects to a blank page titled **Authorization completed** and stuck there
URL:
`https://hypothes.is/oauth/authorize?client_id=631206c8-7792-11e7-90b3-872e79925778&origin=https%3A%2F%2Fhypothes.is&response_mode=web_message&response_type=code&state=d293c1b2c1829b4f`

**### Browser/system information**
Android Webview (Android 6.0.1, SM-N9005)
User agent:
Mozilla/5.0 (Linux; Android 6.0.1; SM-N9005 Build/M4B30X; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/61.0.3163.98 Mobile Safari/537.36

Changing the user agent of the Webview did not help:
For example I tried user agent:
Dalvik/2.1.0 (Linux; U; Android 6.0.1; SM-N9005 Build/M4B30X)

and tried:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.