Line | |
---|
1 | <?php |
---|
2 | |
---|
3 | require_once('IGrantType.php'); |
---|
4 | |
---|
5 | /** |
---|
6 | * Authorization code Grant Type Validator |
---|
7 | */ |
---|
8 | class OAuth2_GrantType_AuthorizationCode implements OAuth2_GrantType_IGrantType |
---|
9 | { |
---|
10 | /** |
---|
11 | * Defines the Grant Type |
---|
12 | * |
---|
13 | * @var string Defaults to 'authorization_code'. |
---|
14 | */ |
---|
15 | const GRANT_TYPE = 'authorization_code'; |
---|
16 | |
---|
17 | /** |
---|
18 | * Adds a specific Handling of the parameters |
---|
19 | * |
---|
20 | * @return array of Specific parameters to be sent. |
---|
21 | * @param mixed $parameters the parameters array (passed by reference) |
---|
22 | */ |
---|
23 | public function validateParameters(&$parameters) |
---|
24 | { |
---|
25 | if (!isset($parameters['code'])) |
---|
26 | { |
---|
27 | throw new OAuth2_InvalidArgumentException( |
---|
28 | 'The \'code\' parameter must be defined for the Authorization Code grant type', |
---|
29 | OAuth2_InvalidArgumentException::MISSING_PARAMETER |
---|
30 | ); |
---|
31 | } |
---|
32 | elseif (!isset($parameters['redirect_uri'])) |
---|
33 | { |
---|
34 | throw new OAuth2_InvalidArgumentException( |
---|
35 | 'The \'redirect_uri\' parameter must be defined for the Authorization Code grant type', |
---|
36 | OAuth2_InvalidArgumentException::MISSING_PARAMETER |
---|
37 | ); |
---|
38 | } |
---|
39 | } |
---|
40 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.