public function RestfulTokenAuthController::generateAccessToken in RESTful 7.2
Create a new access_token entity with a referenced refresh_token.
Parameters
int $uid: The user ID.
Return value
RestfulTokenAuth The created entity.
File
- modules/
restful_token_auth/ src/ Entity/ RestfulTokenAuthController.php, line 23 - Contains Drupal\restful_token_auth\Entity\RestfulTokenAuthController.
Class
Namespace
Drupal\restful_token_auth\EntityCode
public function generateAccessToken($uid) {
$refresh_token = $this
->generateRefreshToken($uid);
// Create a new access token.
$values = array(
'uid' => $uid,
'type' => 'access_token',
'created' => REQUEST_TIME,
'name' => t('Access token for: @uid', array(
'@uid' => $uid,
)),
'token' => drupal_random_key(),
'expire' => $this
->getExpireTime(),
'refresh_token_reference' => array(
LANGUAGE_NONE => array(
array(
'target_id' => $refresh_token->id,
),
),
),
);
$access_token = $this
->create($values);
$this
->save($access_token);
return $access_token;
}