[GH-ISSUE #302] {"errors":[{"code":32,"message":"Could not authenticate you."}]} when trying to submit a post to Twitter? #183

Closed
opened 2026-03-03 16:46:26 +03:00 by kerem · 3 comments
Owner

Originally created by @lanza on GitHub (Oct 31, 2016).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/302

Description: I get the error

{"errors":[{"code":32,"message":"Could not authenticate you."}]}

when I try to submit a post to http://api.twitter.com/1.1/statuses/update.json.

Authorization works just fine. I can get tweets for the main timeline. I can get user information. But when I try to call this post I get this error. Here's the call. The auth and oauthswift are exactly as set in the README.md.

oAuthSwift.client.post("https://api.twitter.com/1.1/statuses/update.json", parameters: ["body":tweet.urlEscaped], headers: nil, success: nil, failure: nil)

OAuth Provider (Twitter, Github, ..):

Twitter

OAuth Version:

  • Version 1
  • Version 2

OS (Please fill the version) :

  • iOS :
  • OSX :
  • TVOS :
  • WatchOS :

Installation method:

  • Carthage
  • CocoaPods
  • Manually

Library version:

  • head
  • v1.0.0
  • v0.6
  • other: (Please fill in the version you are using.)

Xcode version:

  • 8.0 (Swift 3.0)

  • 8.0 (Swift 2.3)

  • 7.3.1

  • other: (Please fill in the version you are using.)

  • objective c

Originally created by @lanza on GitHub (Oct 31, 2016). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/302 ### Description: I get the error {"errors":[{"code":32,"message":"Could not authenticate you."}]} when I try to submit a post to `http://api.twitter.com/1.1/statuses/update.json`. Authorization works just fine. I can get tweets for the main timeline. I can get user information. But when I try to call this post I get this error. Here's the call. The auth and oauthswift are exactly as set in the README.md. oAuthSwift.client.post("https://api.twitter.com/1.1/statuses/update.json", parameters: ["body":tweet.urlEscaped], headers: nil, success: nil, failure: nil) ### OAuth Provider (Twitter, Github, ..): Twitter ### OAuth Version: - [x] Version 1 - [ ] Version 2 ### OS (Please fill the version) : - [x] iOS : - [ ] OSX : - [ ] TVOS : - [ ] WatchOS : ### Installation method: - [ ] Carthage - [x] CocoaPods - [ ] Manually ### Library version: - [x] head - [ ] v1.0.0 - [ ] v0.6 - [ ] other: (Please fill in the version you are using.) ### Xcode version: - [x] 8.0 (Swift 3.0) - [x] 8.0 (Swift 2.3) - [ ] 7.3.1 - [ ] other: (Please fill in the version you are using.) - [ ] objective c
kerem closed this issue 2026-03-03 16:46:26 +03:00
Author
Owner

@phimage commented on GitHub (Oct 31, 2016):

Have you read twitter api?
(For a next issue please give a link to the provider doc, Doc of the request if you can
https://dev.twitter.com/rest/reference/post/statuses/update)
I don't see any 'body' parameter in the doc for that request

<!-- gh-comment-id:257287689 --> @phimage commented on GitHub (Oct 31, 2016): Have you read twitter api? (For a next issue please give a link to the provider doc, Doc of the request if you can https://dev.twitter.com/rest/reference/post/statuses/update) I don't see any 'body' parameter in the doc for that request
Author
Owner

@lanza commented on GitHub (Oct 31, 2016):

Oh oops that was a typo. It does indeed work when calling that function. However, this fails while using the OAuthSwiftAlamofire framework with that same error message.

provider.manager.request("https://api.twitter.com/1.1/statuses/update.json", method: .post, parameters: ["status":tweet.urlEscaped], headers: nil).responseJSON { response in
        print(String(data: response.data!,encoding: .utf8)!)
    }

This returns that same error message. The only thing that differs in the URLRequest being called would be the shouldHandleCookies parameter being true for the AlamoFire adapter version. I edited Alamofire's code to simply change that header and still the same error.

<!-- gh-comment-id:257298273 --> @lanza commented on GitHub (Oct 31, 2016): Oh oops that was a typo. It does indeed work when calling that function. However, this fails while using the OAuthSwiftAlamofire framework with that same error message. ``` provider.manager.request("https://api.twitter.com/1.1/statuses/update.json", method: .post, parameters: ["status":tweet.urlEscaped], headers: nil).responseJSON { response in print(String(data: response.data!,encoding: .utf8)!) } ``` This returns that same error message. The only thing that differs in the URLRequest being called would be the `shouldHandleCookies` parameter being `true` for the AlamoFire adapter version. I edited Alamofire's code to simply change that header and still the same error.
Author
Owner

@phimage commented on GitHub (Oct 31, 2016):

If OAuthSwift work, you can close this issue
And open one for OAuthSwiftAlamofire (you can add a link to this one)

If you have done some debug ie. break point in adapt(_ urlRequest: URLRequest) throws -> URLRequest { to see original urlRequest and modified one

<!-- gh-comment-id:257442829 --> @phimage commented on GitHub (Oct 31, 2016): If OAuthSwift work, you can close this issue And open one for `OAuthSwiftAlamofire` (you can add a link to this one) If you have done some debug ie. break point in `adapt(_ urlRequest: URLRequest) throws -> URLRequest {` to see original `urlRequest` and modified one
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/OAuthSwift#183
No description provided.