5

I am building an Android app that signs in users to GitHub using OAuth. I followed the instructions here to do so. As the first part of the process, I sent users to the URL

https://github.com/login/oauth/authorize?scope=repo&client_id=MY_CLIENT_ID

However, when I sign in on my Android device, the Authorize xxxx button appears to be greyed out and I can't click it. Does anyone have a clue why this is? (Large screenshot below)

I think the button may not have been greyed out before, the first time I ran the app and signed in. However, I can't tell for sure because I was in a rush.

James Ko
  • 32,215
  • 30
  • 128
  • 239

3 Answers3

5

So, I pasted the link into Chrome on my computer and the OAuth process worked fine. I noticed the button was greyed out at first, but then became bright green. This got me wondering: was JavaScript enabled by default in the Android WebView? Sure enough, it wasn't. I found this answer which details how to enable JS. This was the key line that got everything working:

webView.getSettings().setJavaScriptEnabled(true);
James Ko
  • 32,215
  • 30
  • 128
  • 239
  • If i am not using webview , i am using git api , getting the same issue.How can we resolve. clientId="2e9c1001acbdbecef8a9"; String clientSecret="3ba4b54a344820154a175b8907d1229013f11add"; String redirectUrl="futurestudio://calback";, Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/login/oauth/authorize" +"?client_id="+clientId+"&scope=repo&redirect_url="+redirectUrl)); startActivity(intent); – Gyan Swaroop Awasthi Jul 19 '19 at 09:34
0

I absolutely support what @james-ko said - JS has to be enabled for the WebView.

But sometimes it doesn't help. I found a little bit more info and would be happy to share it here.

Similar story - I have an app which is supposed to login the user with GitHub OAuth, everything works fine except the "Authorise" button - it just stays disabled whatever setting were applied is some cases.

Here is summary:

  1. The button is always stays disabled on emulator with API 22 and 23 (I didn't try 24-27 though) regardless of settings and user behaviour.

  2. It works well on emulator with API 28 and 29.

  3. On the real device Pixel 3 (API 29), the button was disabled initially and nothing was happening for a while. But when I taped the screen twice in random places it got enabled. The app restarting reproduces the situation: initially disabled button --> tap on the screen --> button gets enabled.

Apparently some antifraud mechanism is involved.

But it gives kinda poor experience to the final user it looks like a bug in the app and there is not much what we can do about it :-/

Alexander Skvortsov
  • 2,696
  • 2
  • 17
  • 31
0

I had the same problem in Safari, but I located a potential cause, the content security policy of the site was set to: script-src github.githubassets.com

Hg0428
  • 316
  • 4
  • 15