You are here

function _feeds_oauth_store_token in Feeds OAuth 7

Store the access token in our {feeds_oauth_access_tokens} table.

3 calls to _feeds_oauth_store_token()
feeds_oauth_callback in ./feeds_oauth.module
Menu callback to complete authenticating OAuth 1.
feeds_oauth_callback2 in ./feeds_oauth.module
Menu callback to complete authenticating OAuth 2.
feeds_oauth_refresh2 in ./feeds_oauth.module
Menu callback to refresh access tokens for OAuth 2.

File

./feeds_oauth.module, line 117
The module file.

Code

function _feeds_oauth_store_token($token, $uid, $site_id) {
  $timestamp = time();
  $data = array(
    'uid' => $uid,
    'site_id' => $site_id,
    'oauth_token' => $token['access_token'],
    'oauth_token_secret' => isset($token['access_token_secret']) ? $token['access_token_secret'] : '',
    'timestamp' => $timestamp,
    'expires' => isset($token['expires_in']) ? $timestamp + $token['expires_in'] : (isset($token['expires']) ? $timestamp + $token['expires'] : 0),
    'oauth_refresh_token' => isset($token['refresh_token']) ? $token['refresh_token'] : '',
  );
  db_merge('feeds_oauth_access_tokens')
    ->key(array(
    'uid' => $uid,
    'site_id' => $site_id,
  ))
    ->fields($data)
    ->execute();
}