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.
Completed
Push — master ( bce9ad...5c78c2 )
by Joan
11:47
created

Discord::getBaseAuthorizationUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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