<?php include __DIR__ . '/../config.php'; require_once __DIR__ . '/../lib/OAuth/OAuthCodeRequest.php'; use Att\Api\OAuth\OAuthCodeRequest; $scope = "WEBRTCMOBILE"; $codeUrl = $FQDN . '/oauth/v4/authorize'; $codeRequest = new OAuthCodeRequest($codeUrl, $api_key, $scope, $authorize_redirect_uri); $url = $codeRequest->getCodeLocation(); $arr = array('consent_url' => $url); echo json_encode($arr); /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** * Generate the oauth redirect URL depending on the scope requested by the client. * The scope is specified as a parameter in the GET request and passed to the provider * library to obtain the appropriate oAuth URL * * @param {String} scope a comma separated list of services that the app requires access to * @param {String} return_url address to redirect the callback to after authcode is obtained * @param {String} $custom_param a comma separated value to by pass on-net OR suppress landing page * * @return {string} Returns the oAuth URL * @method oauthUrl * */ public function oauthUrl($scope, $return_url, $custom_param) { $encoded_return_url = urlencode($return_url); $redirect_uri = $this->local_server . "/att/callback.php?scopes=" . $scope . "&returnUrl=" . $encoded_return_url; // Create object to get an OAuth Code Location URL $oacr = new OAuthCodeRequest($this->base_url . "/oauth/v4/authorize", $this->client_id, $scope, $redirect_uri); // Append custom param, if it was sent or is set in the config file $oAuthUrl = $oacr->getCodeLocation(); if ($custom_param != null) { if (DEBUG) { Debug::init(); Debug::write("Custom params are: {$custom_param}\n"); Debug::end(); } $oAuthUrl = $oAuthUrl . '&custom_param=' . $custom_param; } if (DEBUG) { Debug::init(); Debug::write("OAuth URL for authorize is: {$oAuthUrl}\n"); Debug::end(); } return $oAuthUrl; }
/** * Gets the URL to redirect an application to for authorization. * * This function uses the parameters specified in the configuration file. * * @return string URL to redirect for authorization */ function getCodeLocation() { $codeUrl = getFqdn() . '/oauth/v4/authorize'; $codeRequest = new OAuthCodeRequest($codeUrl, CLIENT_ID, SCOPE, AUTHORIZE_REDIRECT_URI); return $codeRequest->getCodeLocation(); }