Problem/Motivation
It should be possible to make requests to JSON:API using Drupal Core's basic authentication.
Proposed resolution
The options argument of the ApiClient class will support an additional optional 'authentication' property. Which allows authentication of type 'basic'. If a username and password is provided, requests to JSON:API will be made using basic authentication.
Remaining tasks
* Implement the necessary changes
** Add authentication option. Thinking something similar to:
{
authentication: {
type: 'basic',
username: 'username',
password: 'password'
}
}
** If provided, fetch requests will be made with the following additional header:
Authorization: username:password (base 64 encoded)
* Define necessary types
* Document the current ApiClient class inline.
* Add test coverage.
API changes
* The options object will now include a authentication property.
* Fetch will be updated to set the necessary headers.
Issue fork api_client-3376937
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
brianperryComment #3
pratik_kambleComment #5
pratik_kambleComment #6
coby.sher commentedComment #7
pratik_kambleComment #8
pratik_kambleComment #9
brianperryNoted a couple of other minor things on the MR, but this is really close.
Comment #10
pratik_kambleComment #11
pratik_kambleComment #12
brianperry@pratik_kamble and @CobyPear - made one small change to support authentication with customFetch, so keeping this as needs review. If you're ok with that change, the rest of this is good to go from my perspective.
Comment #14
brianperryMerged - marking as fixed. Great work and back and forth on this one @pratik_kamble and @CobyPear