source: extensions/Google2Piwigo/include/OAuth2/GrantType/AuthorizationCode.php @ 28832

Last change on this file since 28832 was 28832, checked in by mistic100, 10 years ago

fix oauth flow

File size: 1.2 KB
Line 
1<?php
2
3require_once('IGrantType.php');
4
5/**
6 * Authorization code  Grant Type Validator
7 */
8class 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.