OAuth2ClientBundle is an OAuth2 flow manager. Define your API grants, your rendering template and thats all. It manages for you token flows from OAuth2 Protocol. It also provides a direct login to API side. Take a look to the following to get started with OAuth2ClientBundle ;)
Installation is a quick 3 steps process:
- Download SpiritDevOAuth2ClientBundle
- Enable the Bundle
- Configure the SpiritDevOAuth2ClientBundle
The preferred way to install this bundle is to rely on Composer.
Just check on Packagist the version you want to install (in the following example, we used "dev-master") and add it to your composer.json
:
{
"require": {
// ...
"spirit-dev/oauth2-client-bundle": "dev-master"
}
}
Finally, enable the bundle in the kernel:
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new SpiritDev\Bundle\OAuth2ClientBundle\SpiritDevOAuth2ClientBundle(),
);
}
Import the routing.yml configuration file in app/config/routing.yml:
# app/config/routing.yml
spirit_dev_oauth2_client_o_auth:
resource: "@SpiritDevOAuth2ClientBundle/Resources/config/routing.yml"
Add SpiritDevOAuth2ClientBundle settings in app/config/config.yml:
# app/config/config.yml
spirit_dev_o_auth2_client:
api_oauth_settings:
token_uri: "http://your.api.com/oauth/v2/token" // API url to get token
get_user_uri: "http://your.api.com/api/v1/user" // API url to get user informations
client_id: "ExampleOfClientIDProvidedByYourAPI.com" // ClientId Passphrase given by API
client_secret: "ExampleOfClientSecretProvidedByYourAPI.com" // ClientSecret Passphrase given by API
redirect_uri: "http://your.local.app/index" // Internal redirection url after login success
refresh_token_uri: "http://dev.spiritapi.com/check_remote_token" // url to pass to view to reload access_token
login_success_settings:
redirection_type: "twig" // Switch between js and twig to generate redirection // next arriving feature
redirection_template: AcmeDemoBundle:Default:index.html.twig
Now that you have completed the basic installation and configuration of the FOSUserBundle, you are ready to learn about more advanced features and usages of the bundle.
The following documents are available: