Skip to content

Commit

Permalink
[OAuth2] Provider\Discord - started to work ;)
Browse files Browse the repository at this point in the history
  • Loading branch information
ovr committed Mar 12, 2017
1 parent 6f0f840 commit 8c134a7
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions Provider/Discord.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace SocialConnect\OAuth2\Provider;

use SocialConnect\Common\Http\Client\Client;
use SocialConnect\Provider\AccessTokenInterface;
use SocialConnect\Provider\Exception\InvalidAccessToken;
use SocialConnect\Provider\Exception\InvalidResponse;
Expand All @@ -20,23 +21,23 @@ class Discord extends \SocialConnect\OAuth2\AbstractProvider
*/
public function getBaseUri()
{
return 'https://disqus.com/api/3.0/';
return 'https://discordapp.com/api/';
}

/**
* {@inheritdoc}
*/
public function getAuthorizeUri()
{
return 'https://disqus.com/api/oauth/2.0/authorize/';
return 'https://discordapp.com/api/oauth2/authorize';
}

/**
* {@inheritdoc}
*/
public function getRequestTokenUri()
{
return 'https://disqus.com/api/oauth/2.0/access_token/';
return 'https://discordapp.com/api/oauth2/token';
}

/**
Expand All @@ -47,6 +48,14 @@ public function getName()
return 'discord';
}

/**
* @return string
*/
public function getScopeInline()
{
return implode(' ', $this->scope);
}

/**
* {@inheritdoc}
*/
Expand All @@ -70,9 +79,11 @@ public function parseToken($body)
public function getIdentity(AccessTokenInterface $accessToken)
{
$response = $this->httpClient->request(
$this->getBaseUri() . 'users/details',
$this->getBaseUri() . 'users/@me',
[],
Client::GET,
[
'access_token' => $accessToken->getToken()
'Authorization' => 'Bearer ' . $accessToken->getToken()
]
);

Expand All @@ -91,7 +102,11 @@ public function getIdentity(AccessTokenInterface $accessToken)
);
}

$hydrator = new ObjectMap([]);
$hydrator = new ObjectMap(
[
'verified' => 'emailVerified'
]
);

return $hydrator->hydrate(new User(), $result);
}
Expand Down

0 comments on commit 8c134a7

Please sign in to comment.