Skip to content

[HttpClient] Add new bearer option #30547

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

Merged
merged 1 commit into from
Mar 14, 2019
Merged

Conversation

dunglas
Copy link
Member

@dunglas dunglas commented Mar 13, 2019

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets n/a
License MIT
Doc PR n/a

Add a new "auth_bearer" option to set the corresponding flavor of the Authorization header as defined in RFC 6750 and used in OAuth (and others).

Also rename "auth" to "auth_basic" for consistency as discussed with @nicolas-grekas.

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Mar 13, 2019

I thought about it, but do we really need it, when the alternative is that one?
$client->request(..., ['bearer' => $bearer]);
vs
$client->request(..., ['headers' => ['authorization: Bearer '.$bearer]]);

Yes, it's shorter, but adding the option means added burden when implementing the interface.

@nicolas-grekas nicolas-grekas added this to the next milestone Mar 13, 2019
@dunglas
Copy link
Member Author

dunglas commented Mar 13, 2019

Using a Bearer token is very common when requesting an API (more common than Basic). Also, it can be error prone (for instance, your example is wrong because the B of Bearer must be uppercased according to the RFC).

@dunglas
Copy link
Member Author

dunglas commented Mar 13, 2019

Regarding the burden, as this trait isn't internal, it should not be a big deal.

@fabpot fabpot force-pushed the httpclient-bearer branch from f262b78 to f79ef21 Compare March 14, 2019 07:15
@fabpot
Copy link
Member

fabpot commented Mar 14, 2019

Thank you @dunglas.

@fabpot fabpot merged commit f79ef21 into symfony:master Mar 14, 2019
fabpot added a commit that referenced this pull request Mar 14, 2019
This PR was squashed before being merged into the 4.3-dev branch (closes #30547).

Discussion
----------

[HttpClient] Add new bearer option

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes<!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | n/a   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | n/a

Add a new "auth_bearer" option to set the corresponding flavor of the `Authorization` header as defined in RFC 6750 and used in OAuth (and others).

Also rename "auth" to "auth_basic" for consistency as discussed with @nicolas-grekas.

Commits
-------

f79ef21 [HttpClient] Add new bearer option
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.3 Apr 30, 2019
@fabpot fabpot mentioned this pull request May 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants