blob: b124b344f98f346ddb54b1345427aec05516d5cd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
<?php
namespace League\OAuth2\Client\Grant;
use League\OAuth2\Client\Token\AccessToken;
class Password implements GrantInterface
{
public function __toString()
{
return 'password';
}
public function prepRequestParams($defaultParams, $params)
{
if (! isset($params['username']) || empty($params['username'])) {
throw new \BadMethodCallException('Missing username');
}
if (! isset($params['password']) || empty($params['password'])) {
throw new \BadMethodCallException('Missing password');
}
$params['grant_type'] = 'password';
return array_merge($defaultParams, $params);
}
public function handleResponse($response = array())
{
return new AccessToken($response);
}
}
|