Scope在GoogleApiClient中做了什么?

时间:2015-12-01 11:57:13

标签: android google-api android-googleapiclient

任何人都可以解释一下这个addScope(Scope scope)方法在 GoogleApiClient 中做了什么。

new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Plus.API)
.addScope(Plus.SCOPE_PLUS_LOGIN)// what really does this?
.build();

2 个答案:

答案 0 :(得分:2)

范围定义了执行所需操作所需的权限。

如果您的应用需要从用户google云端硬盘帐户中读取,那么您会请求 https://www.googleapis.com/auth/drive.readonly 授予您“read-only access to file metadata and file content”但是如果您需要能够上传谷歌驱动器你可能想要求 https://www.googleapis.com/auth/drive 授予"Full, permissive scope to access all of a user's files."

Scope定义了授予应用程序的访问范围。

问题范围Plus.login https://www.googleapis.com/auth/plus.login

  

这是推荐的社交访问范围   特征。该范围隐含地包括配置文件范围以及   要求您的应用可以访问:
*年龄范围   经过身份验证的用户
*用户拥有的圈出人员列表   授予您的应用程序访问权限以了解用于阅读,书写和阅读的方法   代表用户向Google删除应用活动(片刻)   此外,此范围还支持跨平台单点登录。

答案 1 :(得分:0)

  

范围是允许访问特定资源的字符串,例如   用户数据。

请参阅docscopes summary