1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* SocialConnect project |
4
|
|
|
* @author: Patsura Dmitry https://github.com/ovr <[email protected]> |
5
|
|
|
*/ |
6
|
|
|
declare(strict_types=1); |
7
|
|
|
|
8
|
|
|
namespace SocialConnect\OAuth2\Provider; |
9
|
|
|
|
10
|
|
|
use SocialConnect\Common\ArrayHydrator; |
11
|
|
|
use SocialConnect\Provider\AccessTokenInterface; |
12
|
|
|
use SocialConnect\Common\Entity\User; |
|
|
|
|
13
|
|
|
|
14
|
|
|
class Twitch extends \SocialConnect\OAuth2\AbstractProvider |
15
|
|
|
{ |
16
|
|
|
const NAME = 'twitch'; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* {@inheritdoc} |
20
|
|
|
*/ |
21
|
3 |
|
public function getBaseUri() |
22
|
|
|
{ |
23
|
3 |
|
return 'https://api.twitch.tv/kraken/'; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* {@inheritdoc} |
28
|
|
|
*/ |
29
|
2 |
|
public function getAuthorizeUri() |
30
|
|
|
{ |
31
|
2 |
|
return 'https://api.twitch.tv/kraken/oauth2/authorize'; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* {@inheritdoc} |
36
|
|
|
*/ |
37
|
2 |
|
public function getRequestTokenUri() |
38
|
|
|
{ |
39
|
2 |
|
return 'https://api.twitch.tv/kraken/oauth2/token'; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* {@inheritdoc} |
44
|
|
|
*/ |
45
|
3 |
|
public function getName() |
46
|
|
|
{ |
47
|
3 |
|
return self::NAME; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @return string |
52
|
|
|
*/ |
53
|
1 |
|
public function getScopeInline() |
54
|
|
|
{ |
55
|
|
|
// @link https://github.com/justintv/Twitch-API/blob/master/authentication.md#scopes |
56
|
1 |
|
return implode('+', $this->scope); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* {@inheritDoc} |
61
|
|
|
*/ |
62
|
2 |
|
public function prepareRequest(string $method, string $uri, array &$headers, array &$query, AccessTokenInterface $accessToken = null): void |
63
|
|
|
{ |
64
|
2 |
|
if ($accessToken) { |
65
|
2 |
|
$query['oauth_token'] = $accessToken->getToken(); |
66
|
|
|
} |
67
|
2 |
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* {@inheritdoc} |
71
|
|
|
*/ |
72
|
2 |
|
public function getIdentity(AccessTokenInterface $accessToken) |
73
|
|
|
{ |
74
|
2 |
|
$response = $this->request('GET', 'user', [], $accessToken); |
75
|
|
|
|
76
|
|
|
$hydrator = new ArrayHydrator([ |
77
|
|
|
'_id' => 'id', |
78
|
|
|
'display_name' => 'fullname', // Custom Capitalized Users name |
79
|
|
|
'name' => 'username', |
80
|
|
|
]); |
81
|
|
|
|
82
|
|
|
return $hydrator->hydrate(new User(), $response); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths