2014-04-25 23:27:49 +04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace League\OAuth2\Client\Grant;
|
|
|
|
|
|
|
|
use League\OAuth2\Client\Token\AccessToken as AccessToken;
|
|
|
|
|
|
|
|
class RefreshToken implements GrantInterface
|
|
|
|
{
|
|
|
|
public function __toString()
|
|
|
|
{
|
|
|
|
return 'refresh_token';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function prepRequestParams($defaultParams, $params)
|
|
|
|
{
|
2014-05-03 14:55:30 +04:00
|
|
|
if (! isset($params['refresh_token']) || empty($params['refresh_token'])) {
|
2014-04-25 23:27:49 +04:00
|
|
|
throw new \BadMethodCallException('Missing refresh_token');
|
|
|
|
}
|
|
|
|
|
|
|
|
$params['grant_type'] = 'refresh_token';
|
|
|
|
|
|
|
|
return array_merge($defaultParams, $params);
|
|
|
|
}
|
|
|
|
|
2014-11-09 00:30:40 +03:00
|
|
|
public function handleResponse($response = [])
|
2014-04-25 23:27:49 +04:00
|
|
|
{
|
|
|
|
return new AccessToken($response);
|
|
|
|
}
|
|
|
|
}
|