Overview

Namespaces

  • Authoritarian
    • Exception
      • Flow
    • Flow
  • PHP

Classes

  • AbstractFlow
  • AuthorizationCodeFlow
  • ClientCredentialsFlow
  • ResourceOwnerPasswordFlow
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: namespace Authoritarian\Flow;
 4: 
 5: use Authoritarian\Credential\ClientCredential;
 6: use Authoritarian\Exception\Flow\MissingTokenUrlException;
 7: 
 8: /**
 9:  * Implementation of Resource Owner Password Flow
10:  **/
11: class ResourceOwnerPasswordFlow extends AbstractFlow
12: {
13:     const GRANT_TYPE = 'password';
14: 
15:     protected $username;
16:     protected $password;
17: 
18:     /**
19:      * @param string $username
20:      * @param string $password
21:      */
22:     public function __construct($username, $password)
23:     {
24:         $this->username = $username;
25:         $this->password = $password;
26:     }
27: 
28:     /**
29:      * {@inheritDoc}
30:      */
31:     public function getRequest()
32:     {
33:         parent::getRequest();
34: 
35:         return $this->client->post(
36:             $this->tokenUrl,
37:             $this->getContentTypeFormUrlencodedHeader(),
38:             $this->removeNullItems(
39:                 array(
40:                     'client_id' => $this->clientId,
41:                     'client_secret' => $this->clientSecret,
42:                     'username' => $this->username,
43:                     'password' => $this->password,
44:                     'scope' => $this->scope,
45:                     'grant_type' => self::GRANT_TYPE,
46:                 )
47:             )
48:         );
49:     }
50: 
51:     private function getContentTypeFormUrlencodedHeader()
52:     {
53:         return array(
54:             'Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8',
55:         );
56:     }
57: }
58: 
59: 
API documentation generated by ApiGen 2.8.0