Skip to content

Fix missing Content-Type header on OAuth token request#49

Open
jacksonhuether wants to merge 1 commit intofragment-dev:devfrom
whopio:fix/create-token-content-type
Open

Fix missing Content-Type header on OAuth token request#49
jacksonhuether wants to merge 1 commit intofragment-dev:devfrom
whopio:fix/create-token-content-type

Conversation

@jacksonhuether
Copy link
Contributor

Problem

The create_token method in FragmentClient sends a form-encoded POST body for the OAuth client credentials grant, but does not explicitly set the Content-Type header to application/x-www-form-urlencoded.

While some OAuth servers infer the content type from the body, others — including AWS Cognito — strictly require the header to be present. Without it, these servers return 405 Method Not Allowed because they cannot identify the request as a valid form POST.

Fix

Added post.content_type = "application/x-www-form-urlencoded" to the create_token method, after basic_auth is set and before the body is assigned. This is a one-line, non-breaking change that makes the request conformant with RFC 6749 Section 4.4.2, which specifies that client credentials grant requests use application/x-www-form-urlencoded.

Changes

  • lib/fragment_client.rb: Set Content-Type: application/x-www-form-urlencoded on the token request.

The create_token method sends a form-encoded POST body but does not set
the Content-Type header to application/x-www-form-urlencoded. Some OAuth
servers (including AWS Cognito) return 405 Method Not Allowed when the
header is absent because they cannot identify the request as a valid
form POST.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant