Reputation: 3886
How do you obtain a oAuth2 token using a webView in android? I know how to make a webview and open the url to obtain the oAuth2 token, but I dont know how to switch from the webView back to the app once its obtained, and copy the oAuth2 token into a variable, does anyone know how to do this or know of a good tut? p.s. I'm trying to obtain a oAuth2 token to access a google api
Upvotes: 3
Views: 15552
Reputation: 3170
Maybe this might be late.
But this may help the people who face the similar problem.
I found this tutorial which is useful:
http://www.learn2crack.com/2014/01/android-oauth2-webview.html
Upvotes: 4
Reputation: 3018
Either set it in the title of the WebView window and get it via: http://developer.android.com/reference/android/webkit/WebView.html#getTitle()
Or set a cookie in the WebView and grab it from the cookie. More info here (in section 3.2.2): https://sites.google.com/site/oauthgoog/oauth-practices/mobile-apps-for-complex-login-systems/samplecode
That documentation is geared towards authentication and not authorization/OAuth specifically, but the same underlying techniques still apply.
Upvotes: 3