Search code examples
iosquickblox

Quickblox iOS SDK Signing In using a Facebook access token not working


I'm using the latest Quickblox 2.3.0.4

I cant sign in with Facebook access token.

[QBRequest logInWithSocialProvider:@"facebook" accessToken:[FBSDKAccessToken currentAccessToken].tokenString accessTokenSecret:nil successBlock:^(QBResponse *response, QBUUser *user) {
    NSLog(@"qb login succeed");
} errorBlock:^(QBResponse *response) {
    NSLog(@"qb login failed"); //it hits this
}];

Response header:

Response headers: {
   "Access-Control-Allow-Origin" = "*";
   "Cache-Control" = "no-cache";
    Connection = "keep-alive";
   "Content-Length" = 32;
   "Content-Type" = "application/json; charset=utf-8";
    Date = "Wed, 12 Aug 2015 16:54:47 GMT";
   "QuickBlox-REST-API-Version" = "0.1.1";
   Server = "nginx/1.0.15";
   Status = "401 Unauthorized";
   "X-Rack-Cache" = "invalidate, pass";
   "X-Request-Id" = 607e9709265a701be551a3eea7d4610a;
   "X-Runtime" = "0.003635";
   "X-UA-Compatible" = "IE=Edge,chrome=1";
}

I tested the access token with graph API: https://graph.facebook.com/me?access_token= and it showed valid information.


Solution

  • Based on Quickblox docs:

    In order to use QuickBlox Users APIs (any QuickBlox API) you must create session.

    Try this:

    // Create session request
    [QBRequest createSessionWithSuccessBlock:^(QBResponse *response, QBASession *session) {
        //Your Quickblox session was created successfully
        [QBRequest logInWithSocialProvider:@"facebook" accessToken:[FBSDKAccessToken currentAccessToken].tokenString accessTokenSecret:nil successBlock:^(QBResponse *response, QBUUser *user) {
            NSLog(@"qb login succeed");
        } errorBlock:^(QBResponse *response) {
            NSLog(@"qb login failed");
        }];
    } errorBlock:^(QBResponse *response) {
        //Handle error here
    }];