4
votes

I use the simple code for login to Twitter

[[Twitter sharedInstance] logInWithCompletion:^(TWTRSession *session, NSError *error) {
        if (session != nil) {
            NSLog(@"successful %@",session);
        } else {
            NSLog(@"error: %@", error);
        }
    }];

and sometimes I get the error:

2016-08-04 15:39:14.472 MyProject[11143:132894] [TwitterKit] did encounter error with message "Error attempting to obtain temporary auth token.": Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={NSUnderlyingError=0x7fe043a49830 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, NSErrorFailingURLStringKey=https://api.twitter.com/oauth/request_token, NSErrorFailingURLKey=https://api.twitter.com/oauth/request_token, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=61, NSLocalizedDescription=Could not connect to the server.} 2016-08-04 15:39:14.473 EarCrush[11143:132894] [TwitterKit] did encounter error with message "Unable to authenticate using the system account.": Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={NSUnderlyingError=0x7fe043a49830 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, NSErrorFailingURLStringKey=https://api.twitter.com/oauth/request_token, NSErrorFailingURLKey=https://api.twitter.com/oauth/request_token, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=61, NSLocalizedDescription=Could not connect to the server.}

2016-08-04 15:39:14.473 MyProject[11143:132894] error: Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={NSUnderlyingError=0x7fe043a49830 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, NSErrorFailingURLStringKey=https://api.twitter.com/oauth/request_token, NSErrorFailingURLKey=https://api.twitter.com/oauth/request_token, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=61, NSLocalizedDescription=Could not connect to the server.}

I mean sometimes because:

  • 2 days ago I can login to Twitter normally
  • Yesterday I can not login,
  • This morning I can login but now (afternoon) I can not login even I don't change any code

I have update my Twitter via Fabric to latest version now (2.3) and I'm sure I have internet connection

I know my problem is very strangely but hope someone have a same problem like me can give me some suggestion for fix it

1

1 Answers

2
votes

I had problem with login with Twitter and Firebase. This code working for me:

Twitter.sharedInstance().startWithConsumerKey("key", consumerSecret: "secret")

in AppDelegate. Then, when you tap on your custom login button call this:

Twitter.sharedInstance().logInWithCompletion() { session, error in
        if let session = session { ... })

If you using Fabric, you don't need to call Fabric.with([Twitter.self]).