简体   繁体   English

如何在Android中使用webView获取oAuth2令牌?

[英]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.

相关问题 如何在android中使用webView获取Auth令牌? - How do you obtain a Auth token using webView in android? 如何在 Android 中使用 WebView 获取身份验证令牌? - How do you obtain a Authentication token using WebView in Android? 使用Android AccountManager获取OAuth2令牌? - Obtain OAuth2 token using android AccountManager? 你如何在android中为google apis交换OAuth2令牌的授权码? - How do you exchange Authorization code for a OAuth2 token for google apis in android? 在Android中存储和使用OAuth2令牌的最佳做法? - Best practice in storing and using a OAuth2 Token in Android? Spring Oauth2 无法获取访问令牌问题 - Spring Oauth2 Couldn't Obtain Access Token Issue 使用Spring Oauth2缓存访问令牌 - Cache acces token using Spring Oauth2 XMLHttpRequest 在使用 Android Webview 时被 CORS 策略阻止 - XMLHttpRequest blocked by CORS policy when using Android Webview for Oauth2 Reddit 如何在spring boot 2 oauth2中获得令牌? - How get a token in spring boot 2 oauth2? 您如何在代理后面使用 spring-security OAuth2,但仅对 OAuth 组件使用 ForwardedHeaderTransformer - How do you use spring-security OAuth2 behind a proxy, but only use ForwardedHeaderTransformer for the OAuth components
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM