android - 谷歌登录中的 requestIdToken 和请求 ServerAuthCode 有什么区别

标签 android google-api

当我们从 Android 设备使用 google api 登录时,我无法区分这两者:requestIdToken 和 requestServerAuthCode。

我的要求是为用户提供登录 android 设备的选项,并在登录后将数据同步到我的服务器。 服务器需要验证来自 Android 设备的登录用户请求。我正在考虑使用“requestIdToken”。 在服务器端,我使用谷歌客户端库从 requestIdToken 获取用户信息。

最佳答案

requestIdToken (String serverClientId)

Specifies that an ID token for authenticated users is requested. Requesting an ID token requires that the server client ID be specified.

还有

requestServerAuthCode (String serverClientId)

Specifies that offline access is requested. Requesting offline access requires that the server client ID be specified.

You don't need to use requestIdToken(String) when you use this option. When your server exchanges the code for tokens, an ID token will be returned together (as long as you either use requestEmail() or requestProfile() along with your configuration).

The first time you retrieve a code, a refresh_token will be granted automatically. Subsequent requests will only return codes that can be exchanged for access token.

<子>来自 the docs .

如您在此处所见,requestServerAuthCode() 专门用于请求离线访问。如果不需要,使用 requestIdToken()

关于android - 谷歌登录中的 requestIdToken 和请求 ServerAuthCode 有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39668773/

相关文章:

android - com.google.android.youtube.api.jar.client.RemoteEmbeddedPlayer 中调用的构造函数引发的异常

php - 如何将动态数据加载到谷歌饼图中?

oauth - 通过Google API获取用户信息

android - 获取与一个联系人android关联的所有手机号码

Android Market - 此应用程序可供 0 多个设备使用?

java - 在应用程序 Android 中应用自定义字体后,xml 中 textview 的粗体 textStyle 属性不起作用

google-api - 谷歌日历 API : Calendar usage limits exceeded

javascript - 根据google api计算的距离对php/mysql结果进行排序

api - 用于读取 "plus one"计数的 Google+ API

android - android studio 新项目 checkout 中 GIT 和 GITHub 的区别?