Skip to content
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

[HttpClient] Add new bearer option #30547

Merged
merged 1 commit into from Mar 14, 2019

Conversation

Projects
None yet
7 participants
@dunglas
Copy link
Member

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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.

@dunglas dunglas force-pushed the dunglas:httpclient-bearer branch from 6c793d5 to 190258f Mar 13, 2019

@chalasr chalasr added the HttpClient label Mar 13, 2019

@fabpot

fabpot approved these changes Mar 14, 2019

@fabpot fabpot force-pushed the dunglas:httpclient-bearer branch from f262b78 to f79ef21 Mar 14, 2019

@fabpot

This comment has been minimized.

Copy link
Member

fabpot commented Mar 14, 2019

Thank you @dunglas.

@fabpot fabpot merged commit f79ef21 into symfony:master Mar 14, 2019

1 of 3 checks passed

continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
fabbot.io Your code looks good.
Details

fabpot added a commit that referenced this pull request Mar 14, 2019

feature #30547 [HttpClient] Add new bearer option (dunglas)
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.