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);
}];
You set the
X-Auth-Tokenheader to the Facebook tokenaccessToken, 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.