New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"401 Authorization Required" error with Twitter API bulk create campaign call #648

Closed
chrismerrill1974 opened this Issue Mar 28, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@chrismerrill1974

chrismerrill1974 commented Mar 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?

@chrismerrill1974

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.

@kullfar

This comment has been minimized.

Member

kullfar commented Mar 29, 2016

Hi, very nice. You came with the answer on your question ;-)

@kullfar kullfar closed this Mar 29, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment