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

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

fix oauth flow

File size: 1.1 KB
Line 
1<?php
2
3require_once('IGrantType.php');
4
5/**
6 * Password Parameters
7 */
8class OAuth2_GrantType_Password implements OAuth2_GrantType_IGrantType
9{
10    /**
11     * Defines the Grant Type
12     *
13     * @var string  Defaults to 'password'.
14     */
15    const GRANT_TYPE = 'password';
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['username']))
26        {
27            throw new OAuth2_InvalidArgumentException(
28                'The \'username\' parameter must be defined for the Password grant type',
29                OAuth2_InvalidArgumentException::MISSING_PARAMETER
30            );
31        }
32        elseif (!isset($parameters['password']))
33        {
34            throw new OAuth2_InvalidArgumentException(
35                'The \'password\' parameter must be defined for the Password grant type',
36                OAuth2_InvalidArgumentException::MISSING_PARAMETER
37            );
38        }
39    }
40}
Note: See TracBrowser for help on using the repository browser.