401 Unauthorized on some, but not all, POSTs and GETs


#1

I’m pretty new to this, so the answer will likely be really simple. I’m using Swift.

I seem to be able to POST requests just fine, but I’m having trouble with some GETs. For instance, I can POST direct messages, but when I try to GET them, I get a 401 - Unauthorized. When I try to check the rate limits, I get 401. verify_credentials gets me a 401, too.

I don’t understand how I could, say, send a tweet or a DM but I can’t get any in return?

My app has R,W and DM access, and I looked in the headers of the successful responses which show “x-access-level” = “read-write-directmessages”.

I’m authenticating with

if Twitter.sharedInstance().sessionStore.session() == nil {
            Twitter.sharedInstance().logInWithCompletion { session, error in
                if (session != nil) {
                    /* success, do some stuff */
                } else {
                    print("error: \(error!.localizedDescription)")
                }
            }
        } else {
            /* already logged in - do other stuff */
        }

and each request begins with a

if let userID = Twitter.sharedInstance().sessionStore.session()?.userID {
    let client = TWTRAPIClient(userID: userID)
    /* do some stuff */

So, any idea of my dumb mistake?