PluginProbe
Authorizer / 3.13.0
Authorizer v3.13.0
3.16.0 3.15.3 3.15.2 3.15.1 3.15.0 3.14.3 3.14.4 3.14.2 3.14.1 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.9.0 2.9.1 2.9.10 2.9.11 2.9.12 2.9.13 2.9.2 2.9.3 All 127 releases
authorizer / vendor / league / oauth2-client / src / OptionProvider / HttpBasicAuthOptionProvider.php

HttpBasicAuthOptionProvider.php in Authorizer 3.13.0, at vendor/league/oauth2-client/src/OptionProvider/HttpBasicAuthOptionProvider.php

43 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * This file is part of the league/oauth2-client library
4 *
5 * For the full copyright and license information, please view the LICENSE
6 * file that was distributed with this source code.
7 *
8 * @copyright Copyright (c) Alex Bilbie <hello@alexbilbie.com>
9 * @license http://opensource.org/licenses/MIT MIT
10 * @link http://thephpleague.com/oauth2-client/ Documentation
11 * @link https://packagist.org/packages/league/oauth2-client Packagist
12 * @link https://github.com/thephpleague/oauth2-client GitHub
13 */
14
15 namespace League\OAuth2\Client\OptionProvider;
16
17 use InvalidArgumentException;
18
19 /**
20 * Add http basic auth into access token request options
21 * @link https://tools.ietf.org/html/rfc6749#section-2.3.1
22 */
23 class HttpBasicAuthOptionProvider extends PostAuthOptionProvider
24 {
25 /**
26 * @inheritdoc
27 */
28 public function getAccessTokenOptions($method, array $params)
29 {
30 if (empty($params['client_id']) || empty($params['client_secret'])) {
31 throw new InvalidArgumentException('clientId and clientSecret are required for http basic auth');
32 }
33
34 $encodedCredentials = base64_encode(sprintf('%s:%s', $params['client_id'], $params['client_secret']));
35 unset($params['client_id'], $params['client_secret']);
36
37 $options = parent::getAccessTokenOptions($method, $params);
38 $options['headers']['Authorization'] = 'Basic ' . $encodedCredentials;
39
40 return $options;
41 }
42 }
43