Skip to content

Commit

Permalink
Merge a309f87 into a6c4f88
Browse files Browse the repository at this point in the history
  • Loading branch information
vyskocilpavel committed Jan 6, 2021
2 parents a6c4f88 + a309f87 commit 7659a92
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ $provider = new CILogon\OAuth2\Client\Provider\ORCID([

Note that you can use this in combination with the Sandbox environment (above).

As an [ORCID member](https://orcid.org/about/membership) you will get an information about user authentication method reference('mfa' for users who have enabled two-factor authentication on their ORCID account, and 'pwd' for users who haven’t)

### Refreshing a Token

Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
],
"require": {
"php": ">=5.6.0",
"league/oauth2-client": "~2.0"
"league/oauth2-client": "~2.0",
"ext-json": "*"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
Expand Down
10 changes: 9 additions & 1 deletion src/Provider/ORCID.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,22 @@ protected function checkResponse(ResponseInterface $response, $data)

/**
* Generate a user object from a successful user details request.
* Add information about amr from id_token (Only for member API)
*
* @param object $response
* @param AccessToken $token
* @return ORCIDResourceOwner
*/
protected function createResourceOwner(array $response, AccessToken $token)
{
return new ORCIDResourceOwner($response);
try {
$jwt_payload = explode('.', $token->getValues()['id_token']);
$jwt_payload_base64 = base64_decode(str_pad(strtr($jwt_payload[1], '-_', '+/'), strlen($jwt_payload[1]) % 4, '=', STR_PAD_RIGHT));
$id_token_json = json_decode($jwt_payload_base64, true);
$response['amr'] = $id_token_json['amr'];
} catch (\Exception $exception) { }

return new ORCIDResourceOwner($response);
}

/**
Expand Down

0 comments on commit 7659a92

Please sign in to comment.