ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
demo.php File Reference

Go to the source code of this file.

Functions

 _readline ($prompt='')
 

Variables

 try
 
 $session = SimpleSAML_Session::getSessionFromRequest()
 
 $baseurl = (isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : 'http://mars.foodle.local/simplesaml')
 
 $key = (isset($_SERVER['argv'][2]) ? $_SERVER['argv'][2] : 'key')
 
 $secret = (isset($_SERVER['argv'][3]) ? $_SERVER['argv'][3] : 'secret')
 
 $consumer = new sspmod_oauth_Consumer($key, $secret)
 
 $requestToken = $consumer->getRequestToken($baseurl . '/module.php/oauth/requestToken.php')
 
 $url = $consumer->getAuthorizeRequest($baseurl . '/module.php/oauth/authorize.php', $requestToken, FALSE)
 
 $accessToken = $consumer->getAccessToken( $baseurl . '/module.php/oauth/accessToken.php', $requestToken)
 
 $userdata = $consumer->getUserInfo($baseurl . '/module.php/oauth/getUserInfo.php', $accessToken)
 

Function Documentation

◆ _readline()

_readline (   $prompt = '')

Definition at line 5 of file demo.php.

5  {
6  echo $prompt;
7  return rtrim( fgets( STDIN ), "\n" );
8 }
9 
10 try {
11 
12 
13  // This is the base directory of the SimpleSAMLphp installation
14  $baseDir = dirname(dirname(dirname(dirname(__FILE__))));
15 
16  // Add library autoloader.
17  require_once($baseDir . '/lib/_autoload.php');
18 
19 
20  require_once(dirname(dirname(__FILE__)) . '/libextinc/OAuth.php');
21 
22  // Needed in order to make session_start to be called before output is printed.
24 
25  $baseurl = (isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : 'http://mars.foodle.local/simplesaml');
26  $key = (isset($_SERVER['argv'][2]) ? $_SERVER['argv'][2] : 'key');
27  $secret = (isset($_SERVER['argv'][3]) ? $_SERVER['argv'][3] : 'secret');
28 
29  echo 'Welcome to the OAuth CLI client' . "\n";
31 
32  // Get the request token
33  $requestToken = $consumer->getRequestToken($baseurl . '/module.php/oauth/requestToken.php');
34  echo "Got a request token from the OAuth service provider [" . $requestToken->key . "] with the secret [" . $requestToken->secret . "]\n";
35 
36  // Authorize the request token
37  $url = $consumer->getAuthorizeRequest($baseurl . '/module.php/oauth/authorize.php', $requestToken, FALSE);
38 
39  echo('Go to this URL to authenticate/authorize the request: ' . $url . "\n");
40  system('open ' . $url);
41 
42  _readline('Click enter when you have completed the authorization step using your web browser...');
43 
44  // Replace the request token with an access token
45  $accessToken = $consumer->getAccessToken( $baseurl . '/module.php/oauth/accessToken.php', $requestToken);
46  echo "Got an access token from the OAuth service provider [" . $accessToken->key . "] with the secret [" . $accessToken->secret . "]\n";
47 
48  $userdata = $consumer->getUserInfo($baseurl . '/module.php/oauth/getUserInfo.php', $accessToken);
49 
50 
51  echo 'You are successfully authenticated to this Command Line CLI. ' . "\n";
52  echo 'Got data [' . join(', ', array_keys($userdata)) . ']' . "\n";
53  echo 'Your user ID is : ' . $userdata['eduPersonPrincipalName'][0] . "\n";
54 
55 } catch(Exception $e) {
56  echo 'Error occurred: ' . $e->getMessage() . "\n\n";
57 }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
$session
Definition: demo.php:23
$secret
Definition: demo.php:27
$baseurl
Definition: demo.php:25
$userdata
Definition: demo.php:48
$requestToken
Definition: demo.php:33
$key
Definition: demo.php:26
$consumer
Definition: demo.php:30
$url
Definition: demo.php:37
$accessToken
Definition: demo.php:45
_readline($prompt='')
Definition: demo.php:5
static getSessionFromRequest()
Retrieves the current session.
Definition: Session.php:243

Variable Documentation

◆ $accessToken

◆ $baseurl

◆ $consumer

$consumer = new sspmod_oauth_Consumer($key, $secret)

Definition at line 30 of file demo.php.

Referenced by assQuestionGUI\addBackTab(), sspmod_authtwitter_Auth_Source_Twitter\authenticate(), sspmod_authmyspace_Auth_Source_MySpace\authenticate(), sspmod_authlinkedin_Auth_Source_LinkedIn\authenticate(), ilLTIToolProvider\authenticate(), IMSGlobal\LTI\OAuth\OAuthSignatureMethod_HMAC_SHA1\build_signature(), IMSGlobal\LTI\OAuth\OAuthSignatureMethod_HMAC_SHA256\build_signature(), OAuthSignatureMethod_HMAC_SHA1\build_signature(), OAuthSignatureMethod_PLAINTEXT\build_signature(), IMSGlobal\LTI\OAuth\OAuthRequest\build_signature(), OAuthRequest\build_signature(), assQuestionGUI\cancelSync(), ilObjLTIAdministrationGUI\changeStatusLTIConsumer(), IMSGlobal\LTI\OAuth\OAuthServer\check_nonce(), OAuthServer\check_nonce(), IMSGlobal\LTI\OAuth\OAuthSignatureMethod\check_signature(), OAuthSignatureMethod\check_signature(), IMSGlobal\LTI\OAuth\OAuthServer\check_signature(), OAuthServer\check_signature(), ilLTIToolProvider\checkForShare(), ilObjLTIAdministrationGUI\createLTIConsumer(), ilObjLTIAdministrationGUI\deleteLTIConsumer(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_pdo_sqlite\deleteToolConsumer(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector\deleteToolConsumer(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_mysql\deleteToolConsumer(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_pdo\deleteToolConsumer(), ilLTIDataConnector\deleteToolConsumer(), ilLTIAppEventListener\doCronUpdate(), ilObjLTIAdministrationGUI\editConsumer(), IMSGlobal\LTI\OAuth\OAuthServer\fetch_access_token(), OAuthServer\fetch_access_token(), IMSGlobal\LTI\OAuth\OAuthServer\fetch_request_token(), OAuthServer\fetch_request_token(), sspmod_authmyspace_Auth_Source_MySpace\finalStep(), sspmod_authtwitter_Auth_Source_Twitter\finalStep(), sspmod_authlinkedin_Auth_Source_LinkedIn\finalStep(), IMSGlobal\LTI\OAuth\OAuthRequest\from_consumer_and_token(), OAuthRequest\from_consumer_and_token(), IMSGlobal\LTI\OAuth\OAuthServer\get_consumer(), OAuthServer\get_consumer(), IMSGlobal\LTI\OAuth\OAuthServer\get_token(), OAuthServer\get_token(), IMSGlobal\LTI\ToolProvider\ToolProxy\getConsumer(), ilLTIDataConnector\getGlobalToolConsumerSettings(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_mysql\getToolConsumers(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_pdo\getToolConsumers(), ilLTIDataConnector\getToolConsumers(), ilLTIAppEventListener\handleUpdateStatus(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_mysql\loadToolConsumer(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_pdo\loadToolConsumer(), ilLTIDataConnector\loadToolConsumer(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector\loadToolConsumer(), sspmod_oauth_OAuthStore\lookup_consumer(), sspmod_oauth_OAuthStore\lookup_consumer_by_requestToken(), sspmod_oauth_OAuthStore\lookup_nonce(), IMSGlobal\LTI\ToolProvider\OAuthDataStore\lookup_token(), sspmod_oauth_OAuthStore\lookup_token(), ilAuthProviderLTI\lookupConsumer(), sspmod_oauth_OAuthStore\new_access_token(), sspmod_oauth_OAuthStore\new_request_token(), ilObjQuestionPoolGUI\questionsObject(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_mysql\saveToolConsumer(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector\saveToolConsumer(), IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector_pdo\saveToolConsumer(), ilLTIDataConnector\saveToolConsumer(), IMSGlobal\LTI\OAuth\OAuthRequest\sign_request(), OAuthRequest\sign_request(), IMSGlobal\LTI\ToolProvider\ToolConsumer\signParameters(), assQuestionGUI\sync(), ilObjLTIAdministrationGUI\updateLTIConsumer(), ilLTIProviderObjectSettingGUI\updateSettings(), IMSGlobal\LTI\OAuth\OAuthServer\verify_request(), and OAuthServer\verify_request().

◆ $key

$key = (isset($_SERVER['argv'][2]) ? $_SERVER['argv'][2] : 'key')

Definition at line 26 of file demo.php.

◆ $requestToken

◆ $secret

◆ $session

Definition at line 23 of file demo.php.

◆ $url

$url = $consumer->getAuthorizeRequest($baseurl . '/module.php/oauth/authorize.php', $requestToken, FALSE)

Definition at line 37 of file demo.php.

◆ $userdata

◆ try

try
Initial value:
{
$baseDir = dirname(dirname(dirname(dirname(__FILE__))))

Definition at line 10 of file demo.php.