You are here

function DrupalOAuthDataStore::new_access_token in OAuth 1.0 7.4

Same name and namespace in other branches
  1. 6.3 includes/DrupalOAuthDataStore.inc \DrupalOAuthDataStore::new_access_token()
  2. 6 oauth.module \DrupalOAuthDataStore::new_access_token()
  3. 7.3 includes/DrupalOAuthDataStore.inc \DrupalOAuthDataStore::new_access_token()

Generate a new access token and delete the old request token.

Parameters

DrupalOAuthToken $token_old: The old request token.

OAuthConsumer $consumer: The service consumer information.

Overrides OAuthDataStore::new_access_token

File

includes/DrupalOAuthDataStore.inc, line 124

Class

DrupalOAuthDataStore
Database abstraction class

Code

function new_access_token($token_old, $consumer, $verifier = NULL) {
  module_load_include('inc', 'oauth_common');
  if ($token_old && $token_old->authorized) {
    $token_new = new DrupalOAuthToken(user_password(32), user_password(32), $consumer, array(
      'type' => OAUTH_COMMON_TOKEN_TYPE_ACCESS,
      'uid' => $token_old->uid,
      'services' => isset($token_old->services) ? $token_old->services : NULL,
      'authorized' => 1,
    ));
    $token_old
      ->delete();
    $token_new
      ->write();
    return $token_new;
  }
  throw new OAuthException('Invalid request token');
}