removed parameter "body" in authorization header in post() method to fix OAuth1.0a authorization error #88
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When you use
post()
method with oauth1.0a user context authorization, you should get error response "Unauthorized".Indeed "Unauthorized" error problem like issue #39 has solved with PR #44, but it may be only case that is authorized with bearer token.
The post request path shown in issue #39 demands only bearer token, but not user context authentication.
https://developer.twitter.com/en/docs/twitter-api/tweets/filtered-stream/api-reference/post-tweets-search-stream-rules
Some post request path need OAuth1.0a user context authentication, so current code doesn't work well when you use other post request path.
A purpose of this PR is just fix it.
It is seemed that caused by embeded
body
in the generating authorization header method.I've read the twitter API documentation and it doesn't seem to say that this is required.
But twitter oauth library demands request data because of generating oauth signature.
I think the reason why current code doesn't work well is Twitter API specification change between v1.1 and v2 described as above.
In API v1.1, most of the post request parameters are sent as query parameters.
But, in API v2, some of the post request parameters are sent as JSON body. And it is sent with
'Content-Type': 'application/json'
in current code.According to OAuth1.0a specification,request parameters can be "signature base string" when content type is
application/x-www-form-urlencoded
.but if it's other content type,it is not specified.
https://oauth.net/core/1.0a/#anchor13
(I'm sorry if I'm just not reading it properly)
That's why I commited just 1 line code.
Here's temporary test code what I've prepared for this job.
Current code fails following test code.(returned Unauthorized Error by API)
(※ This code needs some additional environment variable)
testing post mute
Sorry for my awkward request.
I'm not used to use github.
If I'm doing something wrong in this request, or if I've just coded
post()
method as wrong usage,please discard it and fix this error.
(Should I just post issue first?)