403 and 179 error from protected tweet



Using TwitterKit 3.1.1 and running on iOS 9/10.

I got 403 and 179 error from “my” protected tweet when I call GET https://api.twitter.com/1.1/statuses/show.json.

It’s like not happening on Android and api console…

Any issue on TwitterKit on iOS?


Even though I call GET https://api.twitter.com/1.1/account/settings.json, got 403 and 220 when I changed privacy setting to “Protected”.


I’m trying to reproduce this bug but unable to.
I am able to log in to a demo app (with Twitter Kit) using my protected account, and also see the same protected account’s timeline.
Is that the same scenario for you?


Thank you for your help.
Which demo app are you using? Could you share it?

But the scenario is actually same.

Try to login by logInWithCompletion from my developing app using my protected account, and then fetch my tweet by statuses/show.json. But the tweet is posted from another app using my protected account.

According to the behavior, I guess I can’t get proper authToken because I can only access to public tweets.

Originally this issue was happening on TwitterKit 2.8.1. And then updated to TwitterKit 3.1.1, still happening.
When I investigated this on TwitterKit 2.8.1, tried logInWithMethods with TWTRLoginMethodWebBased but still happening.


I’m using - (void)loadTweetWithID:(NSString *)tweetID completion:(TWTRLoadTweetCompletion)completion in TWTRAPIClient.
Have you guys tried using given method instead of making manual network calls?
More information on https://dev.twitter.com/twitterkit/ios/show-tweets


Not yet. Let me try to use the method.


I got same result from loadTweetWithID.
I can get my tweet in case of not protected but can not in case of protected.

This is error log.

error	NSError *	domain: @"TWTRErrorDomain" - code: 4
  _userInfo	__NSDictionaryI *	2 key/value pairs
    [0]	(null)	@"NSLocalizedDescription" : @"Failed to fetch one or more of the following tweet IDs: 911456198574071809."	
    [1]	(null)	@"TweetsNotLoaded" : @"1 element"	
        key	__NSCFConstantString *	@"TweetsNotLoaded"
        value	__NSSingleObjectArrayI *	@"1 element"
            [0]	__NSCFString *	@"911456198574071809"


Hi Kate,

Do you guys have any update or idea?


How are you implementing login in your code? and how are you pass it on to TWTRAPIClient? It seems like you are not passing around their authenticated session correctly to APIClient
For example, if you are using log in button,

        self.loginButton = TWTRLogInButton { session, error in
            if let session = session {
                self.userClient = TWTRAPIClient(userID: session.userID)
            } else {
                print("Failed to log in \(String(describing: error))")
            // do something



We’re using Objective-c and our login code is like the below. We are not using TWTRLogInButton.
Do I have to do something in success case?

I’m just following “Log In Method” here. https://dev.twitter.com/twitterkit/ios/log-in-with-twitter

[[Twitter sharedInstance] logInWithCompletion:^(TWTRSession *session, NSError *error) {
    if (session) {
     // success
    } else {
     // fail


Could you try implementing your code in session? For example:

    [[Twitter sharedInstance] logInWithCompletion:^(TWTRSession *session, NSError *error) {
        if (session) {
            [[[TWTRAPIClient alloc] initWithUserID:session.userID] loadTweetWithID:@"" completion:^(TWTRTweet * tweet, NSError * error) {
                if (tweet) {
                    // display
        } else {
            // fail


Sure. Let me try.


Wow, looks like I can retrieve a protected tweet with your code.

Now I see what was wrong. It’s like I was using guest context. I should use user context.

I changed my code like the below to create TWTRAPIClient.


TWTRSessionStore *store = [[Twitter sharedInstance] sessionStore];
TWTRSession *lastSession = store.session;
TWTRAPIClient *client = [[TWTRAPIClient alloc] init];


TWTRSessionStore *store = [[Twitter sharedInstance] sessionStore];
TWTRSession *lastSession = store.session;
TWTRAPIClient *client = [[TWTRAPIClient alloc] initWithUserID: lastSession.userID];

Thanks a lot!!!


That’s great! Glad to help out!