I am developing an iPhone application which uses Google Plus as one of the social logins. I want to fetch user friends emails.
I use this from Contact API 3.0, and add the access token I get from Google Plus token:
NSString *url=[NSString stringWithFormat:@"https://www.google.com/m8/feeds/contacts/default/full?alt=json&v=3.0&max-results=500&access_token=%@",accessToken];
But it returns the following error:
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>}
You can't fetch a user's friend's email using G+. Google plus requires a users consent before revealing their email address. Since you haven't obtained consent from those users you can't get their email address. And just because someone is in your user's circles does not give your user permission to consent on their behalf.