* @access public
 * @input  1. $client_callback_url is required
 *         2. when called back by Transformable OAuth authentication, 
 *         a request token var 'oauth_token' is required.
 * @output $access_token_key, to import into transformable
 */
if (!defined('AT_INCLUDE_PATH')) {
    // when the script is called back by oauth server,
    define('AT_INCLUDE_PATH', '../../../../include/');
    require_once AT_INCLUDE_PATH . 'vitals.inc.php';
}
require_once 'OAuthUtility.class.php';
require_once "OAuth.php";
global $msg, $_config;
// check whether the transformable url is accessible
if (!OAuthUtility::isAccessible(AT_TILE_OAUTH_REGISTER_CONSUMER_URL)) {
    $msg->addError(array('TILE_AUTHENTICATION_FAIL', _AT('tile_not_accessible')));
    header('Location: ' . AT_BASE_HREF . 'mods/_core/imscp/index.php');
    exit;
}
// check whether the last access token has expired. If not, return it, otherwise, get a new access token.
// skip this step when this script is called by oauth server callback
if (isset($_SESSION['member_id'])) {
    $access_token_key = OAuthUtility::getUnexpiredAccessToken();
}
if ($access_token_key == '') {
    // initialize basic variables
    $sig_method = new OAuthSignatureMethod_HMAC_SHA1();
    // use HMAC signature method as default
    if (!isset($_GET['oauth_token'])) {
        // 1. register consumer