Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Twitter NSURLErrorDomain Code=-1012

I am trying to get the user's contact details by singning up with twitter in my app. I found this project on github which seems really good. I encounter only one problem. If I run it with my new app consumer secret and consumer key codes from twitter it gives me an error :

Error Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be completed. (NSURLErrorDomain error -1012.)" UserInfo=0x6898e80 {NSErrorFailingURLKey=https://api.twitter.com/oauth/request_token, NSErrorFailingURLStringKey=https://api.twitter.com/oauth/request_token, NSUnderlyingError=0x68980e0 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1012.)"}

The output in the console is :

2013-01-16 17:55:24.367 DMTwitterOAuth[3411:c07] current status = Prompt for user data and request token to server
2013-01-16 17:55:24.371 DMTwitterOAuth[3411:c07] current status = Requesting token for current user's auth data...
2013-01-16 17:55:25.433 DMTwitterOAuth[3411:c07] current status = Token received from server

Immediately after I get the alert view in which it says that it encountered a NSURLErrorDomain.

On the other hand, if I run it with some other codes from another twitter app it works, giving me all the details about the user. I just can't understand why for some keys it works, and for some others it doesn't.

like image 252
Teo Avatar asked Jan 16 '13 16:01

Teo


3 Answers

Error code -1012 is kCFURLErrorUserCancelledAuthentication. This should mean that some code somewhere called [sender cancelAuthenticationChallenge:] in response to an authentication challenge. This is likely code inside of DMTwitterOAuth, but it's also possible it's Apple's own code inside the URL-loading system.

like image 64
Mike Abdullah Avatar answered Nov 11 '22 03:11

Mike Abdullah


Make sure that your twitter application access settings are appropriate for what you're trying to do. If you're trying to post a tweet you'll likely need Read and Write access.

See the Application Model docs for more info.

like image 41
alexgophermix Avatar answered Nov 11 '22 02:11

alexgophermix


It can be also just wrong authentication data in request header.

like image 1
Nikita Avatar answered Nov 11 '22 01:11

Nikita