public function Storage::getAccessToken in OAuth2 Server 7
File
- lib/
Drupal/ oauth2_server/ Storage.php, line 85
Class
- Storage
- Provides Drupal storage (through the underlying Entity API) for the library.
Namespace
Drupal\oauth2_serverCode
public function getAccessToken($access_token) {
$token = oauth2_server_token_load($access_token);
if (!$token) {
return FALSE;
}
$token_wrapper = entity_metadata_wrapper('oauth2_server_token', $token);
// If the user is blocked, deny access.
if ($token->uid && !$token_wrapper->user->status
->value()) {
return FALSE;
}
$scopes = array();
foreach ($token_wrapper->scopes as $scope_wrapper) {
$scopes[] = $scope_wrapper->name
->value();
}
// Return a token array in the format expected by the library.
$token_array = array(
'server' => $token_wrapper->client->server
->raw(),
'client_id' => $token_wrapper->client->client_key
->value(),
'user_id' => $token->uid ? $token_wrapper->user->uid
->value() : NULL,
'access_token' => $token_wrapper->token
->value(),
'expires' => (int) $token_wrapper->expires
->value(),
'scope' => implode(' ', $scopes),
);
if (!empty($token_array['user_id']) && module_exists('uuid')) {
$token_array['user_uuid'] = $token_wrapper->user->uuid
->value();
}
// Track last access on the token.
$this
->logAccessTime($token);
return $token_array;
}