You are here

function oauth_common_get_user_provider_tokens in OAuth 1.0 7.3

Same name and namespace in other branches
  1. 6.3 oauth_common.module \oauth_common_get_user_provider_tokens()
  2. 7.4 oauth_common.module \oauth_common_get_user_provider_tokens()

Gets the tokens for a user.

Parameters

string $uid:

string $type:

Return value

array

1 call to oauth_common_get_user_provider_tokens()
oauth_common_page_user_authorizations in ./oauth_common.authorizations.inc
@file Functions related to a user's authorization section

File

./oauth_common.module, line 424

Code

function oauth_common_get_user_provider_tokens($uid) {
  $q = db_select('oauth_common_token', 't')
    ->condition('t.uid', $uid, '=')
    ->condition('t.type', OAUTH_COMMON_TOKEN_TYPE_ACCESS, '=');
  $q
    ->join('oauth_common_provider_token', 'pt', 'pt.tid = t.tid');
  $res = $q
    ->fields('t')
    ->fields('pt', array(
    'created',
    'changed',
    'services',
    'authorized',
  ))
    ->execute();
  $tokens = array();
  while ($token = DrupalOAuthToken::fromResult($res)) {
    $tokens[] = $token;
  }
  return $tokens;
}