Problem/Motivation
Currently, when using the client_credentials grant type, the feeds_http_oauth module sends the client_id and client_secret exclusively in the request body (FORM_PARAMS).
However, many OAuth 2.0 providers (and the OAuth 2.0 specification itself) allow or require these credentials to be sent using HTTP Basic Authentication in the request headers. Without the ability to choose the authentication method, the module cannot connect to APIs that strictly require header-based authentication for client credentials.
Proposed resolution
- Update the
HttpOAuthFetcherplugin to include a new configuration setting: send_client_credentials_in. - Modify
HttpOAuthFetcherFeedFormto add a radio button field ("Send Client ID and secret in:") allowing users to choose between Header and Body. - Use Drupal
#statesto ensure this field is only visible when theclient_credentialsgrant type is selected. - Update
HttpOAuthFetcher::getAccessToken()to respect this configuration:- If Header is selected, send credentials via
Authorization: Basic [base64(id:secret)]. - If Body is selected, send credentials as form parameters (existing behavior).
- If Header is selected, send credentials via
- Update
feeds_http_oauth.schema.ymlto include the new configuration field.
Remaining tasks
Review and testing
User interface changes
A new radio button field is added to the OAuth 2.0 settings section of the feed configuration form. It only appears when "Client Credentials" is the selected grant type.
API changes
None.
Data model changes
Added send_client_credentials_in (string) to the feeds.fetcher.http_oauth configuration mapping.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 3578495-4.patch | 3.96 KB | qusai taha |
Comments
Comment #2
qusai taha commentedComment #3
qusai taha commentedComment #4
qusai taha commentedComment #6
jnicola commentedCode works and looks good, bringing in!
Comment #8
qusai taha commentedThank you, jnicola. Could you please provide credits if this helps improve the module?
Comment #9
jnicola commented