如何在登录时限制Google云端硬盘应用权限

时间:2014-07-19 23:59:13

标签: ios google-drive-api

我正在使用标准iOS Google Drive SDK登录机制,其范围为kGTLAuthScopeDrive(或“https://www.googleapis.com/auth/drive”)。在登录期间,在提供用户名和密码后,视图窗口显示:

This app would like to:
(1) Know who you are on Google
(2) View your email address
(3) View and manage the files and documents in your Google Drive

Some other text.

Cancel Button    Accept Button

这两个按钮从iPhone 5屏幕的底部掉下来,需要向上滚动才能看到并轻敲。我不需要知道“你在谷歌上的人”或“你的电子邮件地址”。我是否可以使用仅管理Google云端硬盘文件的范围,以便“接受”按钮显示在初始视图中而无需向上滚动?或者,是否有其他方法可以自动滚动以显示按钮?

2 个答案:

答案 0 :(得分:0)

不幸的是,没有你想要的范围。如果您查看Drive 'About' request,您就会看到为什么会产生前2个音符。没有允许您管理文件的范围,也没有看到此信息。

"kind": "drive#user",
"displayName": string,
"picture": {
  "url": string
},
"isAuthenticatedUser": boolean,
"permissionId": string,
"emailAddress": string

答案 1 :(得分:0)

评论GoogleAPI文件中的第142行" GTMOAuth2SignIn.m"产生所需的UI效果。不幸的是,登录失败并显示长错误消息。也许了解GoogleAPI登录过程的人可以使其发挥作用。第142行和完整程序如下:

//scope = [GTMOAuth2Authentication scopeWithStrings:scope, emailScope, nil];


- (void)addScopeForGoogleUserInfo {
  GTMOAuth2Authentication *auth = self.authentication;
  if (self.shouldFetchGoogleUserEmail) {
    NSString *const emailScope = @"https://www.googleapis.com/auth/userinfo.email";
    NSString *scope = auth.scope;
    if ([scope rangeOfString:emailScope].location == NSNotFound) {
      //scope = [GTMOAuth2Authentication scopeWithStrings:scope, emailScope, nil];
      auth.scope = scope;
    }
  }

  if (self.shouldFetchGoogleUserProfile) {
    NSString *const profileScope = @"https://www.googleapis.com/auth/userinfo.profile";
    NSString *scope = auth.scope;
    if ([scope rangeOfString:profileScope].location == NSNotFound) {
      scope = [GTMOAuth2Authentication scopeWithStrings:scope, profileScope, nil];
      auth.scope = scope;
    }
  }
}