Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/OAuth2/Provider/Twitch.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ class Twitch extends \SocialConnect\OAuth2\AbstractProvider
*/
public function getBaseUri()
{
return 'https://api.twitch.tv/kraken/';
return 'https://api.twitch.tv/helix/';
}

/**
* {@inheritdoc}
*/
public function getAuthorizeUri()
{
return 'https://api.twitch.tv/kraken/oauth2/authorize';
return 'https://id.twitch.tv/oauth2/authorize';
}

/**
* {@inheritdoc}
*/
public function getRequestTokenUri()
{
return 'https://api.twitch.tv/kraken/oauth2/token';
return 'https://id.twitch.tv/oauth2/token';
}

/**
Expand All @@ -62,7 +62,9 @@ public function getScopeInline()
public function prepareRequest(string $method, string $uri, array &$headers, array &$query, AccessTokenInterface $accessToken = null): void
{
if ($accessToken) {
$query['oauth_token'] = $accessToken->getToken();
$headers['Authorization'] = "Bearer {$accessToken->getToken()}";
$headers['Client-Id'] = $this->consumer->getKey();

Comment thread
ADmad marked this conversation as resolved.
Outdated
}
}

Expand All @@ -71,14 +73,16 @@ public function prepareRequest(string $method, string $uri, array &$headers, arr
*/
public function getIdentity(AccessTokenInterface $accessToken)
{
$response = $this->request('GET', 'user', [], $accessToken);
$response = $this->request('GET', 'users', [], $accessToken);

$hydrator = new ArrayHydrator([
'_id' => 'id',
'id' => 'id',
'display_name' => 'fullname', // Custom Capitalized Users name
'name' => 'username',
Comment thread
slerdev marked this conversation as resolved.
'login' => 'username',
'profile_image_url' => 'pictureURL',
'email' => 'email'
]);

return $hydrator->hydrate(new User(), $response);
return $hydrator->hydrate(new User(), $response['data'][0]);
}
}