GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Discord::getBaseAccessTokenUrl()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the wohali/oauth2-discord-new 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) Joan Touzet <[email protected]>
9
 * @license http://opensource.org/licenses/MIT MIT
10
 * @link https://packagist.org/packages/wohali/oauth2-discord-new Packagist
11
 * @link https://github.com/wohali/oauth2-discord-new GitHub
12
 */
13
14
namespace Wohali\OAuth2\Client\Provider;
15
16
use League\OAuth2\Client\Provider\AbstractProvider;
17
use League\OAuth2\Client\Token\AccessToken;
18
use League\OAuth2\Client\Tool\BearerAuthorizationTrait;
19
use Psr\Http\Message\ResponseInterface;
20
use Wohali\OAuth2\Client\Provider\Exception\DiscordIdentityProviderException;
21
22
class Discord extends AbstractProvider
23
{
24
    use BearerAuthorizationTrait;
25
26
    /**
27
     * API Domain
28
     *
29
     * @var string
30
     */
31
    public $apiDomain = 'https://discordapp.com/api/v6';
32
33
    /**
34
     * Get authorization URL to begin OAuth flow
35
     *
36
     * @return string
37
     */
38 9
    public function getBaseAuthorizationUrl()
39
    {
40 9
        return $this->apiDomain.'/oauth2/authorize';
41
    }
42
43
    /**
44
     * Get access token URL to retrieve token
45
     *
46
     * @param  array $params
47
     *
48
     * @return string
49
     */
50 12
    public function getBaseAccessTokenUrl(array $params)
51
    {
52 12
        return $this->apiDomain.'/oauth2/token';
53
    }
54
55
    /**
56
     * Get provider URL to retrieve user details
57
     *
58
     * @param  AccessToken $token
59
     *
60
     * @return string
61
     */
62 3
    public function getResourceOwnerDetailsUrl(AccessToken $token)
63
    {
64 3
        return $this->apiDomain.'/users/@me';
65
    }
66
67
    /**
68
     * Returns the string that should be used to separate scopes when building
69
     * the URL for requesting an access token.
70
     *
71
     * Discord's scope separator is space (%20)
72
     *
73
     * @return string Scope separator
74
     */
75 9
    protected function getScopeSeparator()
76
    {
77 9
        return ' ';
78
    }
79
80
    /**
81
     * Get the default scopes used by this provider.
82
     *
83
     * This should not be a complete list of all scopes, but the minimum
84
     * required for the provider user interface!
85
     *
86
     * @return array
87
     */
88 6
    protected function getDefaultScopes()
89
    {
90
        return [
91 6
            'identify',
92 2
            'email',
93 2
            'connections',
94 2
            'guilds',
95
            'guilds.join'
96 2
        ];
97
    }
98
99
    /**
100
     * Check a provider response for errors.
101
     *
102
     * @throws IdentityProviderException
103
     * @param  ResponseInterface @response
104
     * @param  array $data Parsed response data
105
     * @return void
106
     */
107 9
    protected function checkResponse(ResponseInterface $response, $data)
108
    {
109 9
        if ($response->getStatusCode() >= 400) {
110 3
            throw DiscordIdentityProviderException::clientException($response, $data);
111
        }
112 6
    }
113
114
    /**
115
     * Generate a user object from a successful user details request.
116
     *
117
     * @param array $response
118
     * @param AccessToken $token
119
     * @return \League\OAuth2\Client\Provider\ResourceOwnerInterface
120
     */
121 3
    protected function createResourceOwner(array $response, AccessToken $token)
122
    {
123 3
        return new DiscordResourceOwner($response);
124
    }
125
}
126