401 unauthorized error after user logs in and attempts to send tweet

ios
oauth
auth
twitterkit
error-codes

#1

Hello, I am trying to have a user login to twitter inside of my iOS application, and then compose and send a tweet.

The user is logging in successfully, but whenever the user attempts to send the tweet, this is the error I get:

2017-09-28 12:46:38.871900-0400 [41223:1940175] Did encounter error sending Tweet: Error Domain=TWTRNetworkingErrorDomain Code=-1011 "Request failed: unauthorized (401)" UserInfo={NSLocalizedFailureReason=, TWTRNetworkingStatusCode=401, NSErrorFailingURLKey=https://api.twitter.com/1.1/statuses/update.json, NSLocalizedDescription=Request failed: unauthorized (401)}

Here is my login and composition code:

TWTRComposerViewController *composer = [TWTRComposerViewController emptyComposer];
    
    // Check if current session has users logged in
    if ([[Twitter sharedInstance].sessionStore hasLoggedInUsers]) {
        composer.delegate = self;
        [self presentViewController:composer animated:YES completion:nil];
    } else {
        [[Twitter sharedInstance] logInWithCompletion:^(TWTRSession *session, NSError *error) {
            if (session) {

                [self presentViewController:composer animated:YES completion:nil];
            } else {
                UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"No Twitter Accounts Available" message:@"You must log in before presenting a composer." preferredStyle:UIAlertControllerStyleAlert];
                [self presentViewController:alert animated:YES completion:nil];
            }
        }];
    }

I have tried regenerating my consumer keys. Is there something I am missing? If the user is logged in, doesn’t that mean the user has been authorized? Any assistance is appreciated. Thank you.