QBankApi.php
public function setTokens(AccessToken $accessToken, AccessToken $refreshToken = null)
    {
        if ($accessToken instanceof AccessToken && false === $accessToken->isExpired()) {
            if ($this->cache instanceof Cache) {
                $this->cache->save(
                    'oauth2accesstoken',
                    serialize($accessToken),
                    $accessToken->getExpires()->getTimestamp() - (new \DateTime())->getTimestamp()
                );
            }
            $this->oauth2Middleware->setAccessToken($accessToken);
        }
        if ($refreshToken instanceof AccessToken && false === $accessToken->isExpired()) {
            if ($this->cache instanceof Cache) {
                $this->cache->save(
                    'oauth2refreshtoken',
                    serialize($refreshToken),
                    $refreshToken->getExpires() instanceof \DateTime ?
                        $refreshToken->getExpires()->getTimestamp() - (new \DateTime())->getTimestamp() :
                        3600 * 24 * 13
                );
            }
            $this->oauth2Middleware->setRefreshToken($refreshToken);
        }
    }
public function setTokens(AccessToken $accessToken, AccessToken $refreshToken = null)
    {
        if ($accessToken instanceof AccessToken && false === $accessToken->isExpired()) {
            if ($this->cache instanceof Cache) {
                $this->cache->save(
                    'oauth2accesstoken',
                    serialize($accessToken),
                    $accessToken->getExpires()->getTimestamp() - (new \DateTime())->getTimestamp()
                );
            }
            $this->oauth2Middleware->setAccessToken($accessToken);
        }
        if ($refreshToken instanceof AccessToken && false === $accessToken->isExpired()) {
            if ($this->cache instanceof Cache) {
                $this->cache->save(
                    'oauth2refreshtoken',
                    serialize($refreshToken),
                    $refreshToken->getExpires() instanceof \DateTime ?
                        $refreshToken->getExpires()->getTimestamp() - (new \DateTime())->getTimestamp() :
                        3600 * 24 * 13
                );
            }
            $this->oauth2Middleware->setRefreshToken($refreshToken);
        }
    }
Sets the tokens used for authentication.

This is normally done automatically, but exposed for transparency reasons.

@param AccessToken      $accessToken
@param AccessToken|null $refreshToken