fix(auth): send form-encoded body with camelCase fields on login#391
fix(auth): send form-encoded body with camelCase fields on login#391Valyrian-Code wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds support for application/x-www-form-urlencoded request bodies in sendRequest, and updates the auth token API to use form-encoded parameters with camelCase keys.
Changes:
- Added
isFormEncodedoption tosendRequestthat sets appropriate content-type header and URL-encodes the body. - Updated
fetchTokenApito useisFormEncoded: trueand renamed token body fields from snake_case to camelCase. - Added corresponding test coverage for the new form-encoded path and updated the auth test expectations.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/api/sendRequest.js | Implements the isFormEncoded branch for headers and body serialization. |
| src/api/sendRequest.test.js | Adds a test verifying form-encoded body and headers. |
| src/api/auth.js | Switches token request to form-encoded and renames body keys to camelCase. |
| src/api/auth.test.js | Updates test to assert the new camelCase body keys. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
~ cc @deo002
|
|
This pull request has conflicts, please rebase to resolve those before we can evaluate the pull request. |
The /tokens endpoint requires application/x-www-form-urlencoded content type and camelCase field names (tokenName, tokenScope, tokenExpire) per the OpenAPI spec. sendRequest was sending JSON and auth.js used snake_case names, causing a 400 error on every login attempt. Add isFormEncoded option to sendRequest and update fetchTokenApi to use it. Signed-off-by: RAJVEER42 <irajveer.bishnoi2310@gmail.com>
a280f1e to
ac281c5
Compare
|
Rebased onto the latest Note on the current state of Verified against the live v2 OpenAPI spec ( Happy to rename the option to |
Fix Login Failure Caused by Incorrect Token Request Format
Fixes #198
This change resolves the login failure originally reported in #198. Two issues combined to cause the
400 Bad Requestresponse fromPOST /tokens:sendRequestalways sentContent-Type: application/json, while the/tokensendpoint requiresapplication/x-www-form-urlencoded(as defined in the OpenAPI specification at/repo/api/v2/openapi).auth.jsused snake_case field names (token_name,token_scope,token_expire), but theTokenRequestschema defines the corresponding fields in camelCase (tokenName,tokenScope,tokenExpire).Changes
Added an
isFormEncodedoption tosendRequestContent-TypeURLSearchParamsUpdated
fetchTokenApito:isFormEncoded: trueUpdated
auth.test.jsto reflect the corrected request payloadAdded test coverage for the
isFormEncodedcode path insendRequest.test.jsHow to Test
Start the development environment:
Open:
Log in using:
fossyfossyExpected Result
Successful login and redirect to the browse page.
Before this fix, every login attempt failed with:
Closes #198.