summaryrefslogtreecommitdiff
path: root/vendor/league/oauth2-client/src/Grant/RefreshToken.php
blob: 86e7f6e9cf317b629ace7a4c68399dd47b3d7c0f (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
<?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)
    {
        if (! isset($params['refresh_token']) || empty($params['refresh_token'])) {
            throw new \BadMethodCallException('Missing refresh_token');
        }

        $params['grant_type'] = 'refresh_token';

        return array_merge($defaultParams, $params);
    }

    public function handleResponse($response = [])
    {
        return new AccessToken($response);
    }
}