auth icon indicating copy to clipboard operation
auth copied to clipboard

About Refresh Token

Open gassan opened this issue 4 years ago • 0 comments

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());
    }

gassan avatar Sep 17 '20 17:09 gassan