skip to Main Content

I have been trying to do Tinder authentication using FB access token and user id. I have successfully integrated FB SDK and got the details. And I followed the API documentation given in link.

But when I call Tinder auth API, I am getting ‘unauthorized 401’ error. Don’t know what I am missing here, please find below the code which I used.

   AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [manager.requestSerializer setValue:accessToken forHTTPHeaderField:@"X-Auth-Token"];
    [manager.requestSerializer setValue:@"Tinder/4.7.1 (iPhone; iOS 9.2; Scale/2.00)" forHTTPHeaderField:@"User-agent"];

    NSString *userId = [[NSUserDefaults standardUserDefaults] valueForKey:FB_LOGGED_IN_USERID_KEY];
    NSDictionary *parameterDic = @{@"facebook_token": accessToken, @"facebook_id": userId};

    [manager POST:TINDER_AUTH_URL parameters:parameterDic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSLog(@"success! %@", responseObject);    
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSLog(@"error: %@", error);
    }];

2

Answers


  1. You set the X-Auth-Token header to the Facebook token accessToken, which may cause the 401 error. You should only set it in the following requests to the Tinder token you will get in the response of the auth request.

    Login or Signup to reply.
  2. Update:

    I’ve created a repo on Github. You’ll get idea how it works. More info: https://tinder.bhavukjain.com

    /***************/

    You’re using the wrong tags:

    Setup the params something like this:

    let params:[String:Any] = ["locale":"en-IN",
                               "force_refresh": false,
                               "facebook_token":token,
                               "facebook_id":fbId]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search