Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign up"401 Authorization Required" error with Twitter API bulk create campaign call #648
Comments
This comment has been minimized.
This comment has been minimized.
chrismerrill1974
commented
Mar 29, 2016
|
The solution is to use the "Content-Type" header with value "application/json;charset=UTF-8”, along with the payload field on Request. The JSON array is then ignored for the purposes of generating the OAuth signature, and the request succeeds with an HTTP 200 OK response. So, you can mark the question "user error" or whichever similar resolution. Its not a bug in the Scribe API. |
This comment has been minimized.
This comment has been minimized.
|
Hi, very nice. You came with the answer on your question ;-) |
kullfar
closed this
Mar 29, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
chrismerrill1974 commentedMar 28, 2016
I have been attempting to bulk create campaigns using the Twitter V1.0 Ads API. The required JSON data for this call via POST is a JSON array, not an object containing key/value pairs.
I tried to use the "payload" parameter to pass up the JSON array. I seem to always get a "401 Authorization Required" error as a response.
I notice that the OAuth Provider for Twitter supports a bytePayload independent of the bodyParams, and that this payload isn't factored into the OAuth signature that's generated. Yet, the bodyParams are factored into the OAuth signature for other calls.
Is it possible that the payload should be considered when the OAuth signature is generated?
This may be an old error or something already resolved, as I'm using Scribe 1.3.7. I'm going to re-try with Scribe 2.5.2 and see if I get the same results.
Related documentation:
Notes based on the Scribe 1.3.7 codebase (1.3.7 tag)
OAuth10aServiceImpl.java:146 getSignature(...) method uses BaseStringExtractorImpl.java to get the baseString
that is used when generating the signature on line 151. We ignore the payload that is part of
the request (org.scribe.model.Request).
BaseStringExtractorImpl.java:30
getSortedAndEncodedParams(...)
This method ignores the payload. It is used in generating the OAuth signature.
Do we ignore the array or is it somehow being considered when generating the signature?