Multi-purpose OAuth client, configurable for a sleuth of providers through the config file.
Via Composer
$ composer require werk365/laraveloauthclient
Publish the config
$ php artisan vendor:publish --provider="Werk365\LaravelOAuthClient\LaravelOAuthClientServiceProvider"
Configure the config using the provided example.
Then use the package as follows:
use Werk365\LaravelOAuthClient\LaravelOAuthClient as OAuth;
// ...
$oauth = new OAuth("vendorname");
// Returns array defined in config
$response = $oauth->getToken($code);
//Returns array defined in config
$response = $oauth->getInfo($accesstoken);
//Returns array defined in config
$response = $oauth->refreshToken($refreshtoken);
Example of config provided, edit values to match vendor spec:
<?php
return [
'vendor1' => [
'client_id' => '1234',
'client_secret' => '12345',
'redirect_uri' => 'https://www.example.com/oauth2/vendor1',
'token' => [
'url' => 'https://login.vendor.example.com/oauth2/token',
'method' => 'POST',
'grant_type' => 'authorization_code',
'fields' => [
'access_token' => 'access_token',
'expires_in' => 'expires_in',
'refresh_token' => 'refresh_token',
],
'auth' => 'body',
],
'refresh' => [
'url' => 'https://login.vendor.example.com/oauth2/token',
'method' => 'POST',
'grant_type' => 'authorization_code',
'fields' => "*",
'auth' => 'body',
],
'info' => [
'url' => 'https://login.vendor.example.com/oauth2/metadata',
'method' => 'GET',
'fields' => [
'metadata1',
'metadata2',
],
],
],
'vendor2' => ['...'],
];
Please see the changelog for more information on what has changed recently.
$ composer test
If you discover any security related issues, please email author email instead of using the issue tracker.