使用OAuth2要求getAuthToken并为gettoken

使用OAuth2要求getAuthToken并为gettoken

本文介绍了概括地说什么是使用OAuth2要求getAuthToken并为gettoken的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在与访问令牌的OAuth 2.0德灵概括地说有什么区别的使用:

When deling with access token OAuth 2.0In a nutshell what's the difference from using:

AccountManager.getAuthToken(oauth2:HTTPS ... userinfo.profile)

和使用谷歌播放:

GoogleAuthUtil.getToken(mActivity, mEmail, mScope)

正如我understand这两人都产生挑战屏幕的用户,在谷歌播放屏幕是用户友好。访问令牌可以有相同的范围吧?这两个调用必须是异步的。 InvalidateToken看起来有在这两个呼叫被检查,并且更?

As I understand it they both produce a challenge screen for the user,the Google Plays screen is user friendlier. The access token can have same scope right?!Both call have to be asynchronously. InvalidateToken looks like it has to be checked for in both calls, and more?

推荐答案

我不知道如何使用谷歌播放服务的OAuth 2.0认证,但服药后快速看一下它,它看起来pretty的有趣,我认为这件事情我可以preFER使用过AccountManager.getAuthToken。

I didn't know about using Google Play services for OAuth 2.0 authentication, but after taking a quick look at it, it looks pretty interesting and I think it's something I could prefer to use over the AccountManager.getAuthToken.

AccountManager.getAuthToken

专家:

  • 可用于所有的Andr​​oid 2.0设备和较新的。
  • 内置在Android和不需要任何单独的SDK。
  • 可用于所有类型的账户有一个认证,不仅是谷歌。

缺点:

  • 在返回可能已过期,所以你总是有一个令牌invalidate令牌并再次提出要求,以确保你有一个有效的令牌。
  • 需要的权限GET_ACCOUNTS和USE_CREDENTIALS。
  • 在挑战赛的屏幕是不是用户友好为Android 2。*
  • Returns a token that may have expired so you always have to invalidate the token and request it again to make sure you have a valid token.
  • Requires the permissions GET_ACCOUNTS and USE_CREDENTIALS.
  • Challenge screen is not user friendly for Android 2.*

GoogleAuthUtil.getToken

专家:

  • 总是返回一个valid令牌。
  • 只有需要许可GET_ACCOUNTS
  • 用户友好的质询屏幕。
  • Recommended由谷歌
  • Always returns a valid token.
  • Only requires the permission GET_ACCOUNTS
  • User friendly challenge screen.
  • Recommended by Google

缺点:

  • 需要Android 2.2及该设备已谷歌播放
  • 需要您下载并包含谷歌Play业务人员在你的应用程序。
  • 您需要register在谷歌API控制台的应用
  • 在只能被用于谷歌的服务,使用的OAuth 2.0
  • Require Android 2.2 and that the device have Google Play
  • Require that you download and include the Google Play services SDK in your app.
  • You need to register your app in the Google API Console
  • Can "only" be used for Google services that uses OAuth 2.0

AccountManager.getAuthToken挑战屏幕上姜饼和冰淇淋三明治

AccountManager.getAuthToken Challenge screen on Gingerbread and Ice Cream Sandwich

GoogleAuthUtil.getToken挑战屏

由于GoogleAuthUtil方法具有很多用户友好的质询屏幕,并且需要在安装时我肯定会使用AccountManager.getAuthToken方法这种方法,而不是每当我可以少权限。因为你总能得到一个有效的令牌,不必麻烦地无效,应该使code简单以及令牌。

Since the GoogleAuthUtil approach has a much user friendlier challenge screen and requires less permissions at install time I would definitely use this approach instead of the AccountManager.getAuthToken approach whenever I can. Since you always get a valid token and don't have to hassle with invalidating the token it should make the code simpler as well.

这篇关于概括地说什么是使用OAuth2要求getAuthToken并为gettoken的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 10:42