You are here

function _oauth_common_token_schema in OAuth 1.0 7.3

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

Contains the token schema - used by oauth_common_schema() as well as latest related update function

1 call to _oauth_common_token_schema()
oauth_common_schema in ./oauth_common.install
Implements hook_schema().

File

./oauth_common.install, line 256
Installation and schema related functions for the OAuth module

Code

function _oauth_common_token_schema() {
  return array(
    'description' => 'Tokens stored on behalf of providers or consumers for request and services accesses.',
    'fields' => array(
      'tid' => array(
        'type' => 'serial',
        'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
        'not null' => TRUE,
      ),
      'csid' => array(
        'description' => 'The {oauth_common_consumer}.csid this token is related to.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'key_hash' => array(
        'description' => 'SHA1-hash of token_key.',
        'type' => 'char',
        'length' => 40,
        'not null' => TRUE,
      ),
      // Key is a reserved word in MySQL so lets avoid that
      'token_key' => array(
        'description' => 'Token key.',
        'type' => 'text',
        'not null' => TRUE,
      ),
      'secret' => array(
        'description' => 'Token secret.',
        'type' => 'text',
        'not null' => TRUE,
      ),
      'expires' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The expiry time for the token, as a Unix timestamp.',
      ),
      'type' => array(
        'description' => 'Token type: request or access.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 1,
      ),
      'uid' => array(
        'description' => 'User ID from {user}.uid.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'callback_url' => array(
        'description' => 'Callback url.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'tid',
    ),
    'indexes' => array(
      'key_hash' => array(
        'key_hash',
      ),
    ),
    'foreign keys' => array(
      'oauth_common_consumer' => array(
        'table' => 'oauth_common_consumer',
        'columns' => array(
          'csid' => 'csid',
        ),
      ),
      'users' => array(
        'table' => 'users',
        'columns' => array(
          'uid' => 'uid',
        ),
      ),
    ),
  );
}