Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About Refresh Token #128

Open
gassan opened this issue Sep 17, 2020 · 0 comments
Open

About Refresh Token #128

gassan opened this issue Sep 17, 2020 · 0 comments

Comments

@gassan
Copy link

gassan commented Sep 17, 2020

Hey!

Issue

May I implement 2 methods in OAuth2\AbstractProvider?

    /**
     * @param string $code
     * @return RequestInterface
     */
    protected function makeRefreshAccessTokenRequest(string $refreshToken): RequestInterface
    {
        $parameters = [
            'refresh_token' => $refreshToken,
            'client_id' => $this->consumer->getKey(),
            'client_secret' => $this->consumer->getSecret(),
            'grant_type' => 'refresh_token',
        ];

        return $this->httpStack->createRequest($this->requestHttpMethod, $this->getRequestTokenUri())
            ->withHeader('Content-Type', 'application/x-www-form-urlencoded')
            ->withBody($this->httpStack->createStream(http_build_query($parameters, '', '&')))
            ;
    }

and

    /**
     * @param string $refreshToken
     *
     * @return AccessToken
     * @throws InvalidAccessToken
     * @throws InvalidResponse
     * @throws \Psr\Http\Client\ClientExceptionInterface
     */
    public function refreshAccessToken(string $refreshToken): AccessToken
    {
        $response = $this->executeRequest(
            $this->makeRefreshAccessTokenRequest($refreshToken)
        );

        return $this->parseToken($response->getBody()->getContents());
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant