java 你如何在android中使用webView获取oAuth2令牌?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11091074/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do you obtain a oAuth2 token using webView in android?
提问by William L.
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
你如何在android中使用webView获取oAuth2令牌?我知道如何制作 webview 并打开 url 以获取 oAuth2 令牌,但是我不知道如何在获取后从 webView 切换回应用程序,并将 oAuth2 令牌复制到变量中,有谁知道该怎么做这个或知道一个好的啧啧?ps 我正在尝试获取 oAuth2 令牌以访问 google api
回答by sky91
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
回答by Ryan Boyd
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. More info here (in section 3.2.2): https://sites.google.com/site/oauthgoog/oauth-practices/mobile-apps-for-complex-login-systems/samplecode
或者在 WebView 中设置一个 cookie 并从 cookie 中抓取它。此处的更多信息(在第 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,但相同的底层技术仍然适用。