Skip to content

Commit

Permalink
[OAuth2] Small fixes for Provider\Yahoo
Browse files Browse the repository at this point in the history
  • Loading branch information
ovr committed Jan 30, 2018
1 parent f6f10cd commit 6216aad
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
5 changes: 5 additions & 0 deletions example/config.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,10 @@ return [
'applicationId' => '',
'applicationSecret' => '',
],
// https://developer.yahoo.com/apps/create/
'yahoo' => [
'applicationId' => '',
'applicationSecret' => '',
],
]
];
15 changes: 9 additions & 6 deletions src/OAuth2/Provider/Yahoo.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,21 @@ public function parseToken($body)

/**
* Retreive userId
* @throws InvalidResponse
*/
private function getCurrentUserId(AccessTokenInterface $accessToken)
{
$parameters = [];
$parameters['format'] = 'json';
$response = $this->httpClient->request(
$this->getBaseUri() . 'me/guid',
$parameters,
[
'format' => 'json'
],
Client::GET,
[
'Authorization' => 'Bearer ' . $accessToken->getToken(),
]
);

if (!$response->isSuccess()) {
throw new InvalidResponse(
'API (get guid) response with error code',
Expand Down Expand Up @@ -134,18 +136,19 @@ public function getIdentity(AccessTokenInterface $accessToken)
if (isset($result->image)) {
$result->image = $result->image->imageUrl;
}
if ($result->emails) {

if (isset($result->emails)) {
// first one should do it, should be the default one
$result->email = reset($result->emails);
$result->email = $result->email->handle;
}

if ($result->ims) {
if (isset($result->ims)) {
$result->username = reset($result->ims);
$result->username = $result->username->handle;
}

if ($result->birthdate) {
if (isset($result->birthdate)) {
$result->birth_date = date('Y-m-d', strtotime($result->birthdate . '/' . $result->birthYear));
}

Expand Down

0 comments on commit 6216aad

Please sign in to comment.