public static function getAuthorizationUrl($redirectUri, $scope, $clientId, $nonce = null, $state = null, $apiContext = null)
{
$apiContext = $apiContext ? $apiContext : new ApiContext();
$config = $apiContext->getConfig();
if ($apiContext->get($clientId)) {
$clientId = $apiContext->get($clientId);
}
$clientId = $clientId ? $clientId : $apiContext->getCredential()->getClientId();
$scope = count($scope) != 0 ? $scope : array('openid', 'profile', 'address', 'email', 'phone', 'https://uri.paypal.com/services/paypalattributes', 'https://uri.paypal.com/services/expresscheckout');
if (!in_array('openid', $scope)) {
$scope[] = 'openid';
}
$params = array('client_id' => $clientId, 'response_type' => 'code', 'scope' => implode(" ", $scope), 'redirect_uri' => $redirectUri);
if ($nonce) {
$params['nonce'] = $nonce;
}
if ($state) {
$params['state'] = $state;
}
return sprintf("%s/signin/authorize?%s", self::getBaseUrl($config), http_build_query($params));
}