#!/usr/bin/env php getRequestToken($baseurl . '/module.php/oauth/requestToken.php'); echo "Got a request token from the OAuth service provider [" . $requestToken->key . "] with the secret [" . $requestToken->secret . "]\n"; // Authorize the request token $url = $consumer->getAuthorizeRequest($baseurl . '/module.php/oauth/authorize.php', $requestToken, FALSE); echo('Go to this URL to authenticate/authorize the request: ' . $url . "\n"); system('open ' . $url); _readline('Click enter when you have completed the authorization step using your web browser...'); // Replace the request token with an access token $accessToken = $consumer->getAccessToken( $baseurl . '/module.php/oauth/accessToken.php', $requestToken); echo "Got an access token from the OAuth service provider [" . $accessToken->key . "] with the secret [" . $accessToken->secret . "]\n"; $userdata = $consumer->getUserInfo($baseurl . '/module.php/oauth/getUserInfo.php', $accessToken); echo 'You are successfully authenticated to this Command Line CLI. ' . "\n"; echo 'Got data [' . join(', ', array_keys($userdata)) . ']' . "\n"; echo 'Your user ID is : ' . $userdata['eduPersonPrincipalName'][0] . "\n"; } catch(Exception $e) { echo 'Error occurred: ' . $e->getMessage() . "\n\n"; }