【发布时间】:2015-06-05 12:02:01
【问题描述】:
我正在开发一个 iPhone 应用程序,它使用 Google Plus 作为社交登录之一。我想获取用户朋友的电子邮件。
我在 Contact API 3.0 中使用它,并添加我从 Google Plus 令牌中获得的访问令牌:
NSString *url=[NSString stringWithFormat:@"https://www.google.com/m8/feeds/contacts/default/full?alt=json&v=3.0&max-results=500&access_token=%@",accessToken];
但它返回以下错误:
错误域=com.alamofire.error.serialization.response Code=-1011 "请求失败:禁止 (403)" UserInfo=0x15a8ea20 {com.alamofire.serialization.response.error.response= { URL:https://www.google.com/m8/feeds/contacts/default/full?alt=json&v=3.0&max-results=500&access_token=ya29.jfgsugfsugfjsgfjsgfhkjsgfjksguljcX3JXwPvEwrvcg } { 状态码:403,标题 { “接受范围”=无; “缓存控制”=“私人,最大年龄=0”; “内容类型”=“应用程序/json;字符集=UTF-8”; 日期 =“格林威治标准时间 2015 年 6 月 5 日星期五 11:34:01”; 过期 =“格林威治标准时间 2015 年 6 月 5 日星期五 11:34:01”; 服务器 = GSE; Vary = "X-Origin, Origin,Accept-Encoding"; "Www-Authenticate" = "承载领域=\"https://accounts.google.com/\", error=insufficient_scope, scope=\"https://www.googleapis.com/auth/contacts\""; “替代协议”=“443:quic,p=1”; “x 内容类型选项”= nosniff; “x-frame-options”=同源; “x-xss-保护”=“1;模式=块”; }},NSErrorFailingURLKey = https://www.google.com/m8/feeds/contacts/default/full?alt=json&v=3.0&max-results=500&access_token=ya29.jfgsugfsugfjsgfjsgfhkjsgfjksguljcX3JXwPvEwrvcg,NSLocalizedDescription =请求失败:禁止(403),com.alamofire.serialization.response.error.data = }
【问题讨论】:
-
您的令牌似乎有额外的空间。
-
@Larme 这不是真正的令牌我没有将真正的令牌放在问题中
-
access_token 的授权范围是什么?
-
@abraham 这是访问令牌范围 signIn.scopes = [NSArray arrayWithObjects:kGTLAuthScopePlusLogin,nil];
-
我在 Google Plus 登录中使用 GPPSignIn
标签: ios google-plus google-content-api