Symfony 5 bundle for dormilich/http-oauth.
Open Issues: 0
- php: >=7.4
- ext-dom: *
- ext-json: *
- ext-mbstring: *
- ext-simplexml: *
- dormilich/http-oauth: dev-main
- psr/http-client-implementation: ^1.0
- psr/http-factory-implementation: ^1.0
- psr/simple-cache-implementation: ^1.0
- symfony/config: ^5.0
- symfony/dependency-injection: ^5.0
- symfony/http-kernel: ^5.0
This package is auto-updated.
Last update: 2023-03-16 13:53:12 UTC
Symfony 5 bundle for
dormilich/http-oauth, which is an extension to
with the purpose of adding OAuth 2.0 authorisation to request that require them. Requests
that do not require authorisation (resp. lack authorisation credentials) are run without
This bundle requires Symfony 5 as well as a PSR-16, PSR-17, and PSR-18 implementation.
However, it makes sense to use
symfony/cache as PSR-16 and
symfony/http-client as PSR-18
implementation in a Symfony project.
You can then install this bundle via composer:
composer require dormilich/http-oauth-bundle
To set up
dormilich/http-client, also install
The configuration is the standard way to set up the OAuth credentials. Without adding at least one type of credentials the authorisation will be ignored.
Single set of credentials for all requests
The most simple setup is when you only have a single set of credentials. This will be used on every request done with the HTTP client (even when no authorisation is required).
# note that the actual credentials should be loaded from the environment dormilich_http_oauth: credentials: default: client: '%env(CLIENT_ID)%' secret: '%env(CLIENT_SECRET)%' server: https://example.com/oauth/token
Credentials for specific resource domains
This is for associating a set of credentials with a set of specific domains (using Google APIs for demonstration). Other requests will not get an Authorization header added.
# this will only add authorisation to requests to googleapis.com (and its subdomains) dormilich_http_oauth: credentials: domains: - client: '%env(CLIENT_ID)%' secret: '%env(CLIENT_SECRET)%' server: https://example.com/oauth/token hosts: googleapis.com
Custom credentials strategy
If neither of these configuration strategies match your case, then you can create your own
credentials provider by creating a class that implements
CredentialsProviderInterface. To make
the extension use this provider, redefine the
CredentialsProviderInterface service with your class.
# services.yaml services: Dormilich\HttpOauth\Credentials\CredentialsProviderInterface: class: App\CustomCredentialsProvider
Alternatively, or if you need to use multiple providers, it suffices to tag these providers. This also works in combination with configured providers.
# services.yaml services: App\CustomCredentialsProvider: tags: dormilich_http_oauth.credentials