2015-06-05 50 views
0

我正在開發一個iPhone應用程序,它使用Google Plus作爲社交登錄之一。我想獲取用戶朋友的電子郵件。從iOS上的Google帳戶接收朋友的電子郵件

我用這個從聯繫人API 3.0,並添加訪問令牌,我從谷歌加令牌獲得:

NSString *url=[NSString stringWithFormat:@"https://www.google.com/m8/feeds/contacts/default/full?alt=json&v=3.0&max-results=500&access_token=%@",accessToken]; 

但它返回以下錯誤:

Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: forbidden (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 } { status code: 403, headers { "Accept-Ranges" = none; "Cache-Control" = "private, max-age=0"; "Content-Type" = "application/json; charset=UTF-8"; Date = "Fri, 05 Jun 2015 11:34:01 GMT"; Expires = "Fri, 05 Jun 2015 11:34:01 GMT"; Server = GSE; Vary = "X-Origin, Origin,Accept-Encoding"; "Www-Authenticate" = "Bearer realm=\" https://accounts.google.com/ \", error=insufficient_scope, scope=\" https://www.googleapis.com/auth/contacts \""; "alternate-protocol" = "443:quic,p=1"; "x-content-type-options" = nosniff; "x-frame-options" = SAMEORIGIN; "x-xss-protection" = "1; mode=block"; } }, NSErrorFailingURLKey= https://www.google.com/m8/feeds/contacts/default/full?alt=json&v=3.0&max-results=500&access_token=ya29.jfgsugfsugfjsgfjsgfhkjsgfjksguljcX3JXwPvEwrvcg , NSLocalizedDescription=Request failed: forbidden (403), com.alamofire.serialization.response.error.data=<7b0a2022 6572726f 72223a20 7b0a2020 22657272 6f727322 3a205b0a 2020207b 0a202020 2022646f 6d61696e 223a2022 676c6f62 616c222c 0a202020 20227265 61736f6e 223a2022 696e7375 66666963 69656e74 5065726d 69737369 6f6e7322 2c0a2020 2020226d 65737361 6765223a 2022496e 73756666 69636965 6e742050 65726d69 7373696f 6e220a20 20207d0a 20205d2c 0a202022 636f6465 223a2034 30332c0a 2020226d 65737361 6765223a 2022496e 73756666 69636965 6e742050 65726d69 7373696f 6e220a20 7d0a7d0a>}

+0

看來你的代幣還有額外的空間。 – Larme

+0

@Larme它不是真正的令牌,我沒有把真正的令牌放在問題 – khaled

+0

授權access_token的範圍是什麼? – abraham

回答

0

你不能取用戶的朋友的電子郵件使用G +。 Google plus需要獲得用戶的同意才能顯示其電子郵件地址。由於您未獲得這些用戶的同意,因此您無法獲取其電子郵件地址。僅僅因爲用戶圈子中有人不允許您的用戶代表他們同意。

相關問題