The Facebook SDK for iOS worked great until now. Since 2 hours ago, I'm constantly receiving the following error message when I'm trying to log in with Facebook:
Error Domain=com.facebook.sdk.core Code=8 "(null)" UserInfo={NSRecoveryAttempter=<_FBSDKTemporaryErrorRecoveryAttempter: 0x7fb060edae20>, com.facebook.sdk:FBSDKGraphRequestErrorGraphErrorCode=2, NSLocalizedRecoverySuggestion=Momentan serverul este ocupat. Te rugăm să încerci din nou., com.facebook.sdk:FBSDKErrorDeveloperMessageKey=An unexpected error has occurred. Please retry your request later., com.facebook.sdk:FBSDKGraphRequestErrorHTTPStatusCodeKey=500, com.facebook.sdk:FBSDKGraphRequestErrorCategoryKey=1, NSLocalizedRecoveryOptions=<CFArray 0x7fb0638b71b0 [0x10c2fea40]>{type = immutable, count = 1, values = (
0 : OK
)}, com.facebook.sdk:FBSDKGraphRequestErrorParsedJSONResponseKey={
body = {
error = {
code = 2;
"fbtrace_id" = Et3O2yEtpV7;
"is_transient" = 1;
message = "An unexpected error has occurred. Please retry your request later.";
type = OAuthException;
};
};
code = 500;
}}
I have verified:
The bundle ID is correct
The parameters are correct - id,email,name,gender,birthday,picture.width(1080).height(1080),bio,location,friends
The SDK is correctly installed (info.plist with all the requirements - fb{app-id} etc)
All the methods inside the AppDelegate are added and are correctly updated for iOS 9
What should I do? I have tested the SDK on another app and there it's working.
I am using following code to handle twitter integration in my Application.
- (IBAction)signInWithTwitter:(id)sender {
NSURL *requestURL = [NSURL URLWithString:#"https://api.twitter.com/oauth/request_token"];
NSURL *accessURL = [NSURL URLWithString:#"https://api.twitter.com/oauth/access_token"];
NSURL *authorizeURL = [NSURL URLWithString:#"https://api.twitter.com/oauth/authorize"];
NSString *scope = #"http://api.twitter.com/";
GTMOAuthAuthentication *auth = [self authForTwitter];
[auth setCallback:#"http://www.noop.com/OAuthCallback"];
GTMOAuthViewControllerTouch *viewController;
viewController = [[GTMOAuthViewControllerTouch alloc] initWithScope:scope
language:nil
requestTokenURL:requestURL
authorizeTokenURL:authorizeURL
accessTokenURL:accessURL
authentication:auth
appServiceName:#"CK12: Twitter"
delegate:self
finishedSelector:#selector(viewController:finishedWithAuth:error:)];
}
- (GTMOAuthAuthentication *)authForTwitter {
GTMOAuthAuthentication *auth = [[GTMOAuthAuthentication alloc] initWithSignatureMethod:kGTMOAuthSignatureMethodHMAC_SHA1
consumerKey:TWITTER_CONSUMER_KEY
privateKey:TWITTER_CONSUMER_SECRET];
[auth setServiceProvider:#"Twitter"];
return auth;
}
My problem is, if I am changing device time i.e making it 1 hour late, then I am getting following error:
Error Domain=com.google.HTTPStatus Code=401 and error message is : failed to validate oauth signature and token .
So can anybody please suggest how to solve this. if system time is wrong then also I want to make it work .
Finally I got solution for this . . . .
One of the reason we get this error "Failed to validate OAuth signature and token"
when system time is wrong . Because OAuth request carry system timestamp parameters with it , so when device time is not within the 5 minutes of twitter server time .we get "Failed to validate OAuth signature and token" .
There are two ways to make it work , if the device time is even wrong .
1.make HTTP HEAD request to an endpoint on api.twitter.com -- you'll get a Date HTTP header in the response that indicates the current time understood by Twitter. You would then convert this to epoch time and adjust your oauth_timestamp values by a determined offset.
2.There's a small iOS library named ios-ntp link: http://code.google.com/p/ios-ntp . use this to get the current Accurate time .
After that i just set the timestamp of OAuth object in the following method
- (GTMOAuthAuthentication *)authForTwitter
{
GTMOAuthAuthentication *auth = [[GTMOAuthAuthentication alloc]
initWithSignatureMethod:kGTMOAuthSignatureMethodHMAC_SHA1
consumerKey:TWITTER_CONSUMER_KEY
privateKey:TWITTER_CONSUMER_SECRET];
[auth setServiceProvider:#"Twitter"];
NSDate * currentdate = //GET ACCURATE DATE HERE ;
[auth setTimestamp:[NSString stringWithFormat:#"%f",[currentdate timeIntervalSince1970]]];
return auth;
}
that's it . . .Happy Coding :)
Can anyone help me , I want to Download the connection of LinkedIn and Add into iPhone Address Book.
I googled it but not getting any help.
I am using following Api :
NSURL *url = [NSURL URLWithString:#"http://api.linkedin.com/v1/people/~/connections"];
and I am getting the response like:
profile {
errorCode = 0;
message = "Access to connections denied";
requestId = GVG2FXA2N0;
status = 403;
timestamp = 1366641414499;
}
There is AddressBook framework for that:
http://developer.apple.com/library/ios/#documentation/ContactData/Conceptual/AddressBookProgrammingGuideforiPhone/
a wrapper library:
http://maniacdev.com/2012/02/open-source-ios-address-book-wrapper-library-providing-automatic-hashing-and-permission-alerts/
Simple tutorial:
http://programming4.us/mobile/9260.aspx
You must be missing r_network scope.Even I was getting same error. But when I added r_network scope the problem resolved
I'm writing StoreKit-related code, and I'm getting some rather troubling error codes when I try to add a purchase to the queue.
So far, I've experienced error codes -1003 and -1004 and I can't find anything about those codes on the internet.
Running a product request returns valid product numbers, so I don't know why calls to [[SKPaymentQueue defaultQueue] addPayment:aPayment]; would fail with this undocumented problem.
The same code also works without the errors on one device but not on another.
The questions I have are, as of yet, unanswered:
What do these codes mean?
How can I mitigate this problem?
Why are they happening for purchase attempts and not for product requests?
Troubleshooting I've done includes regenerating a signing certificate and provisioning profile, changing WiFi networks, cleaning and building and reinstalling all related software and components, and none of these things individually or together have helped fix the problem.
EDIT:
Found a discussion about this on the Apple dev forums, but no one from Apple has responded: https://devforums.apple.com/thread/107121?tstart=75 (iOS developer account required to view)
EDIT:
I was hit with error code -1001 today, to add to this list of inexplicable and intermittent problems. Still no accountability from Apple, that I can find.
EDIT:
I have a suspicion that these error codes are randomly generated and really only indicate that the Sandbox is down. Anyone else experience this problem?
All error codes are on "CFNetwork Errors Codes References" on the documentation (link)
A small extraction for CFURL and CFURLConnection Errors:
kCFURLErrorUnknown = -998,
kCFURLErrorCancelled = -999,
kCFURLErrorBadURL = -1000,
kCFURLErrorTimedOut = -1001,
kCFURLErrorUnsupportedURL = -1002,
kCFURLErrorCannotFindHost = -1003,
kCFURLErrorCannotConnectToHost = -1004,
kCFURLErrorNetworkConnectionLost = -1005,
kCFURLErrorDNSLookupFailed = -1006,
kCFURLErrorHTTPTooManyRedirects = -1007,
kCFURLErrorResourceUnavailable = -1008,
kCFURLErrorNotConnectedToInternet = -1009,
kCFURLErrorRedirectToNonExistentLocation = -1010,
kCFURLErrorBadServerResponse = -1011,
kCFURLErrorUserCancelledAuthentication = -1012,
kCFURLErrorUserAuthenticationRequired = -1013,
kCFURLErrorZeroByteResource = -1014,
kCFURLErrorCannotDecodeRawData = -1015,
kCFURLErrorCannotDecodeContentData = -1016,
kCFURLErrorCannotParseResponse = -1017,
kCFURLErrorInternationalRoamingOff = -1018,
kCFURLErrorCallIsActive = -1019,
kCFURLErrorDataNotAllowed = -1020,
kCFURLErrorRequestBodyStreamExhausted = -1021,
kCFURLErrorFileDoesNotExist = -1100,
kCFURLErrorFileIsDirectory = -1101,
kCFURLErrorNoPermissionsToReadFile = -1102,
kCFURLErrorDataLengthExceedsMaximum = -1103,
I have similar problems, in my case seem to be related to network connectivity:
Error Domain=NSURLErrorDomain Code=-1001 "The request timed out."
Things to check:
Is there any chance that your server is not able to respond within some time limit? Like 60 seconds or 4 minutes?
Is there a possibility that your device is switching networks (WiFi, 3G, VPN)?
Could someone (client vs. server) be waiting for authentication?
Sorry, no ideas how to fix. Just debugging this, trying to find out what the problem is (-1021, -1001, -1009)
Update: Google search was very kind to find this:
-1001 TimedOut - it took longer than the timeout which was alotted.
-1003 CannotFindHost - the host could not be found.
-1004 CannotConnectToHost - the host would not let us establish a connection.
see NSURLError.h Define
NSURLErrorUnknown = -1,
NSURLErrorCancelled = -999,
NSURLErrorBadURL = -1000,
NSURLErrorTimedOut = -1001,
NSURLErrorUnsupportedURL = -1002,
NSURLErrorCannotFindHost = -1003,
NSURLErrorCannotConnectToHost = -1004,
NSURLErrorNetworkConnectionLost = -1005,
NSURLErrorDNSLookupFailed = -1006,
NSURLErrorHTTPTooManyRedirects = -1007,
NSURLErrorResourceUnavailable = -1008,
NSURLErrorNotConnectedToInternet = -1009,
NSURLErrorRedirectToNonExistentLocation = -1010,
NSURLErrorBadServerResponse = -1011,
NSURLErrorUserCancelledAuthentication = -1012,
NSURLErrorUserAuthenticationRequired = -1013,
NSURLErrorZeroByteResource = -1014,
NSURLErrorCannotDecodeRawData = -1015,
NSURLErrorCannotDecodeContentData = -1016,
NSURLErrorCannotParseResponse = -1017,
NSURLErrorAppTransportSecurityRequiresSecureConnection NS_ENUM_AVAILABLE(10_11, 9_0) = -1022,
NSURLErrorFileDoesNotExist = -1100,
NSURLErrorFileIsDirectory = -1101,
NSURLErrorNoPermissionsToReadFile = -1102,
NSURLErrorDataLengthExceedsMaximum NS_ENUM_AVAILABLE(10_5, 2_0) = -1103,
// SSL errors
NSURLErrorSecureConnectionFailed = -1200,
NSURLErrorServerCertificateHasBadDate = -1201,
NSURLErrorServerCertificateUntrusted = -1202,
NSURLErrorServerCertificateHasUnknownRoot = -1203,
NSURLErrorServerCertificateNotYetValid = -1204,
NSURLErrorClientCertificateRejected = -1205,
NSURLErrorClientCertificateRequired = -1206,
NSURLErrorCannotLoadFromNetwork = -2000,
// Download and file I/O errors
NSURLErrorCannotCreateFile = -3000,
NSURLErrorCannotOpenFile = -3001,
NSURLErrorCannotCloseFile = -3002,
NSURLErrorCannotWriteToFile = -3003,
NSURLErrorCannotRemoveFile = -3004,
NSURLErrorCannotMoveFile = -3005,
NSURLErrorDownloadDecodingFailedMidStream = -3006,
NSURLErrorDownloadDecodingFailedToComplete =-3007,
NSURLErrorInternationalRoamingOff NS_ENUM_AVAILABLE(10_7, 3_0) = -1018,
NSURLErrorCallIsActive NS_ENUM_AVAILABLE(10_7, 3_0) = -1019,
NSURLErrorDataNotAllowed NS_ENUM_AVAILABLE(10_7, 3_0) = -1020,
NSURLErrorRequestBodyStreamExhausted NS_ENUM_AVAILABLE(10_7, 3_0) = -1021,
NSURLErrorBackgroundSessionRequiresSharedContainer NS_ENUM_AVAILABLE(10_10, 8_0) = -995,
NSURLErrorBackgroundSessionInUseByAnotherProcess NS_ENUM_AVAILABLE(10_10, 8_0) = -996,
NSURLErrorBackgroundSessionWasDisconnected NS_ENUM_AVAILABLE(10_10, 8_0)= -997,
I use the following method in my project
-(NSArray*)networkErrorCodes
{
static NSArray *codesArray;
if (![codesArray count]){
#synchronized(self){
const int codes[] = {
//kCFURLErrorUnknown, //-998
//kCFURLErrorCancelled, //-999
//kCFURLErrorBadURL, //-1000
//kCFURLErrorTimedOut, //-1001
//kCFURLErrorUnsupportedURL, //-1002
//kCFURLErrorCannotFindHost, //-1003
kCFURLErrorCannotConnectToHost, //-1004
kCFURLErrorNetworkConnectionLost, //-1005
kCFURLErrorDNSLookupFailed, //-1006
//kCFURLErrorHTTPTooManyRedirects, //-1007
kCFURLErrorResourceUnavailable, //-1008
kCFURLErrorNotConnectedToInternet, //-1009
//kCFURLErrorRedirectToNonExistentLocation, //-1010
kCFURLErrorBadServerResponse, //-1011
//kCFURLErrorUserCancelledAuthentication, //-1012
//kCFURLErrorUserAuthenticationRequired, //-1013
//kCFURLErrorZeroByteResource, //-1014
//kCFURLErrorCannotDecodeRawData, //-1015
//kCFURLErrorCannotDecodeContentData, //-1016
//kCFURLErrorCannotParseResponse, //-1017
kCFURLErrorInternationalRoamingOff, //-1018
kCFURLErrorCallIsActive, //-1019
//kCFURLErrorDataNotAllowed, //-1020
//kCFURLErrorRequestBodyStreamExhausted, //-1021
kCFURLErrorFileDoesNotExist, //-1100
//kCFURLErrorFileIsDirectory, //-1101
kCFURLErrorNoPermissionsToReadFile, //-1102
//kCFURLErrorDataLengthExceedsMaximum, //-1103
};
int size = sizeof(codes)/sizeof(int);
NSMutableArray *array = [[NSMutableArray alloc] init];
for (int i=0;i<size;++i){
[array addObject:[NSNumber numberWithInt:codes[i]]];
}
codesArray = [array copy];
}
}
return codesArray;
}
Then I just check the error code and show alert if it is in the list
if ([[self networkErrorCodes] containsObject:[NSNumber
numberWithInt:[error code]]]){
// Fire Alert View Here
}
But as you can see I commented out codes that I think does not fit to my definition of NO INTERNET. E.g the code of -1012 (Authentication fail.)
You may edit the list as you like.
In my project I use it at username/password entering from user. And in my view (physical) network connection errors could be the only reason to show alert view in your network based app. In any other case (e.g. incorrect username/password pair) I prefer to do some custom user friendly animation, OR just repeat the failed attempt again without any attention of the user. Especially if the user didn't explicitly initiated a network call.
Regards to martinezdelariva for a link to documentation.
I found a new error code which is not documented above:
CFNetworkErrorCode -1022
Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection."
I found this page in the documentation which has an objective-c enum for all of the error codes under the NSURLErrorDomain.
https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Constants/index.html#//apple_ref/doc/constant_group/URL_Loading_System_Error_Codes