You are here

function oauth_user in OAuth 1.0 6

Implementation of hook_user

Used to provide consumer key/secret for consumers

File

./oauth.module, line 67

Code

function oauth_user($op, &$edit, $account, $category) {
  global $user;
  switch ($op) {
    case 'view':
      if ($account->uid == $user->uid && user_access("consume provided services") || $user->uid == 1) {
        $consumer = oauth_get_consumer($account->uid);
        $account->content['consumer_key'] = array();
        $account->content['consumer_key'] += array(
          '#type' => 'user_profile_category',
          '#attributes' => array(
            'class' => 'user-member',
          ),
          '#weight' => 5,
          '#title' => t('External services'),
        );
        $account->content['consumer_key']['request_url'] = array(
          '#type' => 'user_profile_item',
          '#title' => t('Request token URL'),
          '#value' => url('oauth/request', array(
            'absolute' => TRUE,
          )),
          '#weight' => 1,
        );
        $account->content['consumer_key']['auth_url'] = array(
          '#type' => 'user_profile_item',
          '#title' => t('User authentication URL'),
          '#value' => url('oauth/auth', array(
            'absolute' => TRUE,
          )),
          '#weight' => 2,
        );
        $account->content['consumer_key']['access_url'] = array(
          '#type' => 'user_profile_item',
          '#title' => t('Access token URL'),
          '#value' => url('oauth/access', array(
            'absolute' => TRUE,
          )),
          '#weight' => 3,
        );
        $account->content['consumer_key']['key'] = array(
          '#type' => 'user_profile_item',
          '#title' => t('Consumer key'),
          '#value' => $consumer->key,
          '#weight' => 4,
        );
        $account->content['consumer_key']['secret'] = array(
          '#type' => 'user_profile_item',
          '#title' => t('Consumer secret'),
          '#value' => $consumer->secret,
          '#weight' => 5,
        );
      }
      break;
  }
}