[英]How do you obtain a oAuth2 token using webView in android?
How do you obtain a oAuth2 token using a webView in android? 如何在Android中使用WebView获取oAuth2令牌? 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?
我知道如何制作一个webview并打开URL以获取oAuth2令牌,但是我不知道如何在获取到它之后从webView切换回应用程序,并将oAuth2令牌复制到一个变量中,有人知道如何做吗还是知道这个好家伙? ps I'm trying to obtain a oAuth2 token to access a google api
ps我正在尝试获取oAuth2令牌以访问Google API
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 http://www.learn2crack.com/2014/01/android-oauth2-webview.html
Either set it in the title of the WebView window and get it via: http://developer.android.com/reference/android/webkit/WebView.html#getTitle () 在WebView窗口的标题中进行设置,然后通过以下网址获取它: http : //developer.android.com/reference/android/webkit/WebView.html#getTitle ()
Or set a cookie in the WebView and grab it from the cookie. 或在WebView中设置cookie,然后从cookie中获取它。 More info here (in section 3.2.2): https://sites.google.com/site/oauthgoog/oauth-practices/mobile-apps-for-complex-login-systems/samplecode
更多信息,请参见此处(第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. 该文档专门用于身份验证,而不是专门用于授权/ OAuth,但是相同的基础技术仍然适用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.