Testing OAuth

Last updated on
30 April 2025

After the installation of the OAuth module and the modules that OAuth depends on is finished, go to /admin/settings/oauth/list.

1) Create an OAuth context, by clicking the "add context" link.

Below are some properties copied from oauthloginprovider module as an example:

$context = new stdClass;
$context->disabled = FALSE; /* Edit this to true to make a default context disabled initially */
$context->name = 'oauthlogin';
$context->title = 'OAuth login';
$context->authorization_options = array(
  'access_token_lifetime' => '120',
  'page_title' => 'Login to @appname',
  'message' => 'Hi @user! Click on the "login" button to log in to @appname. This will log you in to @appname and give it access to details like your username and email, but not to your password.',
  'warning' => 'Click here if you didn\'t ask to be logged in to @appname.',
  'deny_access_title' => 'Cancel',
  'grant_access_title' => 'Login',
  'disable_auth_level_selection' => 1,
  'signature_methods' => array(
    0 => 'HMAC-SHA1',
    1 => 'HMAC-SHA256',
    2 => 'HMAC-SHA384',
    3 => 'HMAC-SHA512',
  ),
  'default_authorization_levels' => array(
    0 => 'user_info',
  ),
);
$context->authorization_levels = array(
  'user_info' => array(
    'title' => 'Yes, I want to log in to @appname as @user',
    'description' => 'This will log you in to @appname and give it access to details like your username and email, but not to your password.',
  ),
);

Please copy and paste the values into your OAuth Context configuration

2) Create a consumer key by going to your user profile page, and click Application, then add application (/user/*/applications).
Give your application a name, a callback URL (http://yoursite.com/oauth/request_token), and choose the context that we created early in section 1.

Note: Anything other than http://yoursite.com/oauth/request_token gives a Page Not Found error. It might be a bug.

After creating an application, click Edit to view the detailed information. We will need Consumer key and Consumer secret.

3) Find a OAuth Client, for example: http://somesite.com/oauth/example/client.php

a) Get a Request Token:
Put your request token url, it is http://yoursite.com/oauth/request_token
Enter a Consumer key and Consumer secret.
You will see something like oauth_token=c5zqDpWuU5Lt2k3exXPYjHeLiRQHQWyQ&oauth_token_secret=yjUmFEHtERQRFFAjAQ8n4LGbBuV6kbH8,if not, something else is wrong, and you should go back to fix the problem first.

a) We need the oauth_token and oauth_token_secret for this second step ---- Authorizing
Put your authorizing url, it's http://yoursite.com/oauth/authorize
Put oauth_token and oauth_token

b) To be continued....

Help improve this page

Page status: Not set

You can: