-
Notifications
You must be signed in to change notification settings - Fork 214
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
Add bodyserializer/accept header to openverse api client to correctly authenticate with the API #5330
base: main
Are you sure you want to change the base?
Conversation
Latest k6 run output1
Footnotes
|
packages/js/api-client/src/auth.ts
Outdated
return new URLSearchParams(body).toString() | ||
}, | ||
headers: { | ||
Accept: "x-www-form-encoded", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accept: "x-www-form-encoded", | |
"Content-Type": "x-www-form-encoded", |
Sorry, I've mixed up the headers in the issue. The correct one will be content type, to encode the body of the request (and not the response)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skipped this myself, thanks for spotting. Updated now.
… authenticate with the API
ec7db68
to
c108fab
Compare
Add bodyserializer/accept header to openverse api client to correctly authenticate with the API
Fixes
Fixes #5314 by @obulat
Description
The @openverse/api-client package sends the requests for token to the Openverse Django API with the correct parameters but does not serialize the body to the required x-www-form-urlencoded format. This causes the requests to be sent with an empty body. The new changes adds a bodySerializer1 that creates new URLSearchParams from the body object, and stringifies it, thus allowing requests to be sent with correct body objects.
Checklist
Update index.md
).main
) or a parent feature branch.ov just catalog/generate-docs
for catalogPRs) or the media properties generator (
ov just catalog/generate-docs media-props
for the catalog or
ov just api/generate-docs
for the API) where applicable.Developer Certificate of Origin
Developer Certificate of Origin