Overview

Namespaces

  • Authoritarian
    • Exception
      • Flow
    • Flow
  • PHP

Classes

  • OAuth2

Interfaces

  • AuthorizationInterface
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: namespace Authoritarian;
 4: 
 5: /**
 6:  * Implementation of AuthorizationInterface for OAuth2
 7:  **/
 8: class OAuth2 implements AuthorizationInterface
 9: {
10:     protected $client;
11:     protected $tokenUrl;
12: 
13:     /**
14:      * @param string $token_url The URL to request the Access Token
15:      */
16:     public function __construct($token_url)
17:     {
18:         $this->tokenUrl = $token_url;
19:     }
20: 
21:     public function setHttpClient(\Guzzle\Http\ClientInterface $client)
22:     {
23:         $this->client = $client;
24:     }
25: 
26:     /**
27:      * {@inheritDoc}
28:      */
29:     public function requestAccessToken(Flow\AbstractFlow $flow)
30:     {
31:         if (is_null($this->client)) {
32:             $this->client = new \Guzzle\Http\Client();
33:         }
34: 
35:         $flow->setHttpClient($this->client);
36:         $flow->setTokenUrl($this->tokenUrl);
37: 
38:         return $flow->getRequest()->send();
39:     }
40: }
41: 
42: 
API documentation generated by ApiGen 2.8.0