iOS Twitter NSURLErrorDomain Code=-1012
Asked Answered
A

6

8

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.

Arrearage answered 16/1, 2013 at 16:6 Comment(0)
S
6

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.

Sadism answered 9/4, 2013 at 8:46 Comment(0)
Y
1

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.

Yadirayaeger answered 18/4, 2013 at 19:12 Comment(1)
Error code -1012 can be due to an authentication challenge. In my case, a Twitter account existed in Settings, but was not logged in for some reason. Once I entered the password for the account, everything worked perfectly.Drida
A
1

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

Archean answered 10/2, 2014 at 16:40 Comment(0)
C
0

Visit the below url it solves the issue generally not in specific to this twitter context.It will give u some idea

https://mcmap.net/q/1099321/-nsurlerrordomain-error-1012

I hope this helps..

Cutaneous answered 29/7, 2013 at 9:28 Comment(0)
U
0

I have recently found this problem occurring in projects where previously Twitter login was working. For this reason I assumed it was due to the change in iOS or maybe an upgrade in the Twitter feature.

One of the main issues is it is almost impossible to recreate this issue, there is a very interesting twitter community blog talking about it here: https://twittercommunity.com/t/ios-twitter-kit-1-10-1-twtrloginbutton-responds-with-1012-error/52766

The Twitter staff are trying to fix this issue but can't recreate it to see what is going wrong.

The problem seems to be that the users Twitter account has become disconnected from their device. This means that the Twitter Auth Helper can't get your details to login correctly.

The way to fix this is to go into settings -> Twitter and then click on your Twitter account name. For me this then prompted me to re-input my password as the account wasn't currently connected. Very frustrating and difficult to find as there is no indication until you click your Twitter account.

I found this solution applied when attempting to login with a Twitter account using Firebase.

Underpart answered 25/11, 2015 at 4:49 Comment(0)
M
0

According to Twitter, the fix is live in SDK version 1.14.1.

Mezzanine answered 24/1, 2016 at 23:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.