Esempio n. 1
0
 /**
  * Handle the request.
  *
  * @return  void
  *
  * @since   1.0
  */
 public function execute()
 {
     // Verify that we have an OAuth 2.0 application.
     $this->initialise();
     // Generate temporary credentials for the client.
     $credentials = new ROauth2Credentials($this->request);
     // Getting the client object
     $client = $this->fetchClient($this->request->client_id);
     // Doing authentication using Joomla! users
     $credentials->doJoomlaAuthentication($client);
     // Load the JUser class on application for this client
     $this->app->loadIdentity($client->_identity);
     // Initialize the credentials for this request
     $credentials->initialise($client->_identity->username, $this->app->get('oauth.tokenlifetime', 'PT1H'));
     // Build the response for the client.
     $response = array('oauth_code' => $credentials->getTemporaryToken(), 'oauth_state' => true);
     // Set the response code and body.
     $this->response->setHeader('status', '200')->setBody(json_encode($response))->respond();
 }