Fetch friends email from Google Account on iOS - ios

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.

Related

Swift / iOS: Error to post image to Pinterest

Im getting this error while posting image to Pinterest
Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: unauthorized (401)" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x144603bd0> { URL: https://api.pinterest.com/v1/pins/ } { status code: 401, headers {
"Accept-Ranges" = bytes;
"Cache-Control" = private;
Connection = close;
"Content-Length" = 177;
"Content-Type" = "application/json";
Date = "Sun, 10 Jul 2016 19:38:00 GMT";
"Pinterest-Generated-By" = "devplatform-devapi-prod-de3d740a";
"Pinterest-Version" = bcdafd3;
Server = nginx;
"X-Content-Type-Options" = nosniff;
"X-Pinterest-RID" = 480720869025;
"X-Varnish" = 2958547338;
} }, NSErrorFailingURLKey=https://api.pinterest.com/v1/pins/, com.alamofire.serialization.response.error.data=<7b227374 61747573 223a2022 6661696c 75726522 2c202263 6f646522 3a20332c 2022686f 7374223a 20226465 76706c61 74666f72 6d2d6465 76617069 2d70726f 642d6465 33643734 3061222c 20226765 6e657261 7465645f 6174223a 20225375 6e2c2031 30204a75 6c203230 31362031 393a3338 3a303020 2b303030 30222c20 226d6573 73616765 223a2022 41757468 6f72697a 6174696f 6e206661 696c6564 2e222c20 22646174 61223a20 6e756c6c 7d>, NSLocalizedDescription=Request failed: unauthorized (401)}
Here is my code:
PDKClient.sharedInstance().createPinWithImage(image, link: NSURL(string:"http://domain"), onBoard: "MyBoard", description: caption, progress: {percent in
print(percent)
}, withSuccess: {PDKResponseObject in
print("ok")
print(PDKResponseObject.boards())
}, andFailure: {error in
print(error)
})
Error 401 means one of the following.
1.Authentication failed.
2.Authorization failed.
3.You are not permitted to access that resource.
Double check your permissions, check your session token expired or not.
So I think that there is nothing wrong with your code, or the request. It's something with the permissions you have in your Pinterest app.
Try changing the request URL from http to https.
Check the parameters you sending to Pinterest, check whether the parameter names are correct or not, as specified in Pinterest documentation. Also those parameters has the proper type of data, I mean do not pass String in the place of Integer value.
.

QuickBlox v2.6 Facebook login issue

I have one issue facebook signing with quickblox api.
After getting AccessToken by using FBSDK.
[QBRequest logInWithSocialProvider:#"facebook" accessToken:accessToken accessTokenSecret:nil successBlock:^(QBResponse *response, QBUUser *user) {
} errorBlock:^(QBResponse *response) {}
i think facebook returns correct token string.
CAAVS4qDIQb4BAMS7pTl3P1EmtW1ZCOOpbTCQFWrBI8QsA7ufOTYapjF3rEpW1ojZChgOZB7mj6AWDocDSdtxFbksqP3FyZCIou6bUC6ON4ZCRFGPes6TBzufh68A9fBSSz6baTYCZCTIyZAoDhYdBZAvrHF3609cAiEZCesnWrtqYleqPv7YHIadrWf2x1oWItypF3V3pbDgsHd7MSSCcZBvK4yuHGeCUvf7qMPFznuRZCfwNCOcQBDU8ynHnzDPpnnhLEZD
[logInWithSocialProvider: accessToken: ...] function returns following error
[QBResponse], status: 422
2015-12-09 14:27:27.049 NudgeBuddies[2598:124844] [QBCore] Response error: Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: client error (422)" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7ffde266ce40> { URL: https://api.quickblox.com/login.json } { status code: 422, headers {
"Access-Control-Allow-Origin" = "*";
"Cache-Control" = "no-cache";
Connection = "keep-alive";
"Content-Length" = 47;
"Content-Type" = "application/json; charset=utf-8";
Date = "Wed, 09 Dec 2015 06:27:26 GMT";
"QB-Token-ExpirationDate" = "2015-12-09 08:27:26 UTC";
"QuickBlox-REST-API-Version" = "0.1.1";
Server = "nginx/1.6.2";
Status = "422 Unprocessable Entity";
"X-Rack-Cache" = "invalidate, pass";
"X-Request-Id" = ab3443c24c0d5ee0a18d796eaf996cb7;
"X-Runtime" = "0.221723";
"X-UA-Compatible" = "IE=Edge,chrome=1";
} }, NSErrorFailingURLKey=https://api.quickblox.com/login.json, com.alamofire.serialization.response.error.data=<7b226572 726f7273 223a7b22 62617365 223a5b22 4c6f6769 6e206f72 20656d61 696c2072 65717569 72656422 5d7d7d>, NSLocalizedDescription=Request failed: client error (422)}
Please Help me.
How can i solve this problem?
Regards.
In QuickBlox SDK 2.6.5 we have improved stability and we have enabled detail logging so you are able to see the reasons why problem happens.
QuickBlox has open source project Q-municate with Facebook login and you can check it by yourself.
Thanks!

XingClient not working on ios9

I am using same client as I have used in iOS 8.4 but client is not working in iOS 9.
Same code is working in iOS 8.4 but it is not working in iOS 9 I don't know but it is weird my app stop working.
As from iOS 9 we have to set security key in info.plist which I am setting but still client is still not working.
I am getting below error :
Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: unauthorized (401)" UserInfo={com.alamofire.serialization.response.error.response= { URL: https://api.xing.com/v1/request_token } { status code: 401, headers {
"Cache-Control" = "no-cache";
Connection = "Keep-Alive";
"Content-Encoding" = gzip;
"Content-Length" = 93;
"Content-Type" = "application/json; charset=utf-8";
Date = "Tue, 01 Sep 2015 06:29:16 GMT";
"Keep-Alive" = "timeout=5, max=56";
Server = Apache;
"Set-Cookie" = "c_=baca882ff97bd2cf6a18b395933613a0; domain=.xing.com; path=/; expires=Mon, 27 Aug 2035 06:29:16 -0000; secure; HttpOnly";
Status = "401 Unauthorized";
Vary = "Accept-Encoding";
"X-Content-Type-Options" = nosniff;
"X-Frame-Options" = SAMEORIGIN;
"X-Logjam-Request-Action" = "WebService::OauthController#request_token";
"X-Logjam-Request-Id" = "xws-production-85b5a502132e496daedb58968863026a";
"X-Powered-By" = "Phusion Passenger 4.0.59";
"X-Request-Id" = "e82a4a5e-5876-4e1d-9017-85dbbbd1a0f4";
"X-Runtime" = "0.012464";
"X-XSS-Protection" = "1; mode=block";
} }, NSErrorFailingURLKey=https://api.xing.com/v1/request_token, com.alamofire.serialization.response.error.data=<7b226d65 73736167 65223a22 496e7661 6c696420 4f417574 68207369 676e6174 75726522 2c226572 726f725f 6e616d65 223a2249 4e56414c 49445f4f 41555448 5f534947 4e415455 5245227d>, NSLocalizedDescription=Request failed: unauthorized (401)}
I have added below code in my info.plist:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
I using referring code from below URL:
https://github.com/xing/XNGAPIClient

Instagram API, AFNetworking 2.0 iOS client 400 error

I haven't changed anything in my app and my code seems to generate the proper URL with access token attached, but I am getting a 400 error bad request for the past day. It doesn't seem as if Instagram has changed the endpoint. Can someone help me decipher the error log to see if there is any usable info here to help me debug? Access Token x'd out.
Failure Error Domain=AFNetworkingErrorDomain Code=-1011 "Request failed: bad request (400)"
UserInfo=0x9261450 {NSErrorFailingURLKey=https://api.instagram.com/v1/locations/search?lat=37.785834&lng=-122.406417&distance=50&access_token=XXXX, AFNetworkingOperationFailingURLResponseErrorKey=<NSHTTPURLResponse: 0x92627d0> { URL: https://api.instagram.com/v1/locations/search?lat=37.785834&lng=-122.406417&distance=50&access_token=XXXX }
{ status code: 400, headers {
"Cache-Control" = "private, no-cache, no-store, must-revalidate";
Connection = "keep-alive";
"Content-Language" = en;
"Content-Type" = "application/json; charset=utf-8";
Date = "Tue, 26 Aug 2014 05:19:53 GMT";
Expires = "Sat, 01 Jan 2000 00:00:00 GMT";
Pragma = "no-cache";
Server = nginx;
"Set-Cookie" = "csrftoken=26b1980509fc8303e630689c2d483074; expires=Tue, 25-Aug-2015 05:19:53 GMT; Max-Age=31449600; Path=/, ccode=US; Path=/";
"Transfer-Encoding" = Identity;
Vary = "Cookie, Accept-Language";
"X-Ratelimit-Limit" = 5000;
"X-Ratelimit-Remaining" = 4999;
} }, NSLocalizedDescription=Request failed: bad request (400)}

iOS, RESTKit and oAuth - simple sample not working

I am writing a simple application on iOS and I am trying to consume a RESTFull webservice
To have some tips and get some knowledge I first start with twitter without using ios integrated libs, but I always get stocked on Auth.
Any working sample or link will be appreciated, as reminder twitter is not my final goal
For instance this is one of my code, based on RestKit and AFOAuth1Client :
NSURL *url = [NSURL URLWithString:#"https://api.twitter.com"];
AFOAuth1Client * twitterClient = [[AFOAuth1Client alloc] initWithBaseURL:url key:kCLIENTID secret:kCLIENTSECRET];
[twitterClient authorizeUsingOAuthWithRequestTokenPath:#"oauth/request_token"
userAuthorizationPath:#"oauth/authorize"
callbackURL:[NSURL URLWithString:#"af-twitter://success"]
accessTokenPath:#"oauth/access_token"
accessMethod:#"POST"
scope:#""
success:^(AFOAuth1Token *token, id responseObject) {
}
failure:^(NSError *error) {
}];
as you can see it does not work :
2013-06-17 16:59:01.389 restKitTest[14490:c07] I restkit:RKLog.m:34 RestKit logging initialized...
2013-06-17 16:59:02.653 restKitTest[14490:c07] I restkit.network:RKObjectRequestOperation.m:174 POST 'http://api.twitter.com/oauth/request_token'
2013-06-17 16:59:03.051 restKitTest[14490:c07] E restkit.network:RKObjectRequestOperation.m:203 POST 'http://api.twitter.com/oauth/request_token' (401 Unauthorized) [0.3980 s]: Error Domain=AFNetworkingErrorDomain Code=-1011 "Expected status code in (200-299), got 401" UserInfo=0x9c96640 {NSLocalizedRecoverySuggestion=Failed to validate oauth signature and token, AFNetworkingOperationFailingURLRequestErrorKey=<NSMutableURLRequest: 0x9877e20> { URL: http://api.twitter.com/oauth/request_token }, NSErrorFailingURLKey=http://api.twitter.com/oauth/request_token, NSLocalizedDescription=Expected status code in (200-299), got 401, AFNetworkingOperationFailingURLResponseErrorKey=<NSHTTPURLResponse: 0x9aac910> { URL: http://api.twitter.com/oauth/request_token } { status code: 401, headers {
"Cache-Control" = "no-cache, no-store, must-revalidate, pre-check=0, post-check=0";
"Content-Encoding" = gzip;
"Content-Length" = 62;
"Content-Type" = "text/html; charset=utf-8";
Date = "Mon, 17 Jun 2013 14:59:03 GMT";
Expires = "Tue, 31 Mar 1981 05:00:00 GMT";
"Last-Modified" = "Mon, 17 Jun 2013 14:59:03 GMT";
Pragma = "no-cache";
Server = tfe;
"Set-Cookie" = "_twitter_sess=BAh7CDoPY3JlYXRlZF9hdGwrCOJ3pVI%252FAToHaWQiJTIyYzUxN2UwNmUwYTI4%250AYzU1NmU0OTYxZDA5MDcwMmI3IgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVy%250AOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsA--3291687666d367b6ccddc74513532bf56ea144d9; domain=.twitter.com; path=/; HttpOnly, guest_id=v1%3A137148114312677519; Domain=.twitter.com; Path=/; Expires=Wed, 17-Jun-2015 14:59:03 UTC";
Status = "401 Unauthorized";
Vary = "Accept-Encoding";
"x-frame-options" = SAMEORIGIN;
"x-mid" = af106773611449e1226d5dd5d531b64d91e4f3f8;
"x-runtime" = "0.01153";
"x-transaction" = 24e58d8eb3b7cdb5;
"x-ua-compatible" = "IE=10,chrome=1";
"x-xss-protection" = "1; mode=block";
} }}
"401 Unauthorized" indicates that your credentials are incorrect. So check your API keys.
try this:
[twitterClient authorizeUsingOAuthWithRequestTokenPath:#"/oauth/request_token"
userAuthorizationPath:#"/oauth/authorize"
callbackURL:[NSURL URLWithString:#"instantshare-twitter://success"]
accessTokenPath:#"/oauth/access_token"
accessMethod:#"POST"
scope:nil
success:^(AFOAuth1Token *accessToken, id responseObject) {
[twitterClient registerHTTPOperationClass:[AFJSONRequestOperation class]];
} failure:^(NSError *error) {
NSLog(#"Error: %#", error);
}];
Note the line scope:nil, for some reason it doesn't work with empty string.
Among other things, check your application settings in twitter. I'm not sure if this is the case, but I enabled Allow this application to be used to Sign in with Twitter and set Callback URL to some random valid url

Resources