Create a new refresh token_name.

@param RefreshTokenEntityInterface $refreshTokenEntity
@throws \Exception
331608
public function persistNewRefreshToken(RefreshTokenEntityInterface $refreshTokenEntity)
    {
        $this->getEntityManager()->transactional(function(EntityManagerInterface $em) use ($refreshTokenEntity) {
            $em->persist($refreshTokenEntity);
        });
    }
1119682
public function refreshToken($refreshToken)
	{
		$response = $this->http->get($this->getUrl('action/openapi/token'), array(
			'client_id'		=>	$this->appid,
			'client_secret'	=>	$this->appSecret,
			'grant_type'	=>	'refresh_token',
			'redirect_uri'	=>	$this->getRedirectUri(),
			'refresh_token'	=>	$refreshToken,
			'dataType'		=>	'json',
		));
		$this->result = $response->json(true);
		if(!isset($this->result['error']))
		{
			return $this->accessToken = $this->result['access_token'];
		}
		else
		{
			throw new ApiException(isset($this->result['error_description']) ? $this->result['error_description'] : '', $response->httpCode());
		}
	}
1267698
public function refreshToken(AccessToken $accessToken)
    {
        // request data
        $refreshToken = $accessToken->getRefreshToken();
        $scope        = $accessToken->getScope();

        if (empty($refreshToken)) {
            throw new RuntimeException('No refresh token was set');
        }

        $data = array(
            'grant_type'    => 'refresh_token',
            'refresh_token' => $refreshToken,
        );

        if (!empty($scope)) {
            $data['scope'] = $scope;
        }

        // authentication
        $header = array();

        if ($this->type == self::AUTH_BASIC) {
            $header['Authorization'] = 'Basic ' . base64_encode($this->clientId . ':' . $this->clientSecret);
        }

        if ($this->type == self::AUTH_POST) {
            $data['client_id']     = $this->clientId;
            $data['client_secret'] = $this->clientSecret;
        }

        $request  = new PostRequest($this->url, $header, $data);
        $response = $this->httpClient->request($request);

        $data = Json\Parser::decode($response->getBody());

        if ($response->getStatusCode() == 200) {
            return $this->newToken($data);
        } else {
            throw new RuntimeException('Could not refresh access token');
        }
    }
620797
public RefreshTokenResponse refreshToken(String grantType, String refreshToken) throws ApiException {
        ApiResponse<RefreshTokenResponse> resp = refreshTokenWithHttpInfo(grantType, refreshToken);
        return resp.getData();
    }
1197524
public function getToken($refresh = false)
    {
        if ($this->token === null || $refresh)
        {
            $salt = $this->_createSalt(12);
            $name = session_name();

            $this->token = sha1($salt.$name);
        }

        return $this->token;
    }
635897
public function setRefreshTokenStorage(RefreshTokenInterface $storage)
    {
        $storage->setServer($this);
        $this->refreshTokenStorage = $storage;

        return $this;
    }
227696
public function refreshToken(): string
    {
        $data = $this->client->performApiCallWithJsonResponse('get', '/refresh_token');
        $data = (array) json_decode($data);

        if (array_key_exists('token', $data)) {
            return $data['token'];
        }

        throw new TokenNotFoundInResponseException('No token found in response.');
    }
261595
public function readTokenByRefreshValue(string $refreshValue): ?\Limoncello\OAuthServer\Contracts\TokenInterface
    {
        return $this->getIntegration()->getTokenRepository()->readByRefresh(
            $refreshValue,
            $this->getIntegration()->getTokenExpirationPeriod()
        );
    }
1316526
public function refreshAccessToken(TokenInterface $token)
    {
        $refreshToken = $token->getRefreshToken();

        if (empty($refreshToken)) {
            throw new MissingRefreshTokenException();
        }

        $parameters = [
            'grant_type'    => 'refresh_token',
            'type'          => 'web_server',
            'client_id'     => $this->credentials->getConsumerId(),
            'client_secret' => $this->credentials->getConsumerSecret(),
            'refresh_token' => $refreshToken,
        ];

        $responseBody = $this->httpRequest(
            $this->getAccessTokenEndpoint(),
            $parameters,
            $this->getExtraOAuthHeaders()
        );
        $token = $this->parseAccessTokenResponse($responseBody);
        $this->storage->storeAccessToken($this->service(), $token);

        return $token;
    }
90389
public function refreshToken() {
    if ($this->apiClient->getAccessToken() != null) {
      $dbh = new PDO('sqlite:examples.sqlite');
      $this->saveToken($dbh, true, $this->apiClient->getAccessToken());
    }
  }
956287
public function update(RefreshTokenEntity $entity)
    {
        $dbValueArray = $entity->getDbValues();

        $condition = ['refresh_token' => $entity->getRefreshToken()];

        $query = $this->getSqlObject()
            ->update()
            ->set($dbValueArray)
            ->where($condition);

        $this->execute($query);

        return $entity;
    }
683716
protected function createAccessTokenFromRefreshToken(Token $refreshToken)
    {
        $logger = $this->getLogger();
        $logger->debug('Starting request to create fresh access token from refresh token');

        $body = [
            'client_id' => 'anonymous',
            'grant_type' => 'refresh_token',
            'refresh_token' => $refreshToken->getTokenString(),
        ];

        $response = $this->sendPostRequest($body);

        $logger->debug('Successfully retrieved new access token', $response);

        return new Token(
            $response['access_token'],
            $this->tokenExtractor->extract($response['access_token'])
        );
    }
492850
public function getRefreshToken($refresh_token)
    {
        $token = $this->collection('refresh_token_table')->findOne(array(
            'refresh_token' => $refresh_token
        ));
        return is_null($token) ? false : $token;
    }
172770
protected function issueRefreshToken(AccessTokenEntityInterface $accessToken, ClientEntityInterface $client = null)
    {
        $maxGenerationAttempts = self::MAX_RANDOM_TOKEN_GENERATION_ATTEMPTS;

        $refreshToken = $this->refreshTokenRepository->getNewRefreshToken();
        $refreshToken->setAccessToken($accessToken);
        $refreshToken->setUUID($accessToken->getUUID());

        $refresh_expire = $client->getRefreshExpire();

        if(!empty($refresh_expire)){
            $refreshToken->setExpiryDateTime(now()->addMinutes($refresh_expire));
        }else{
            $refreshToken->setExpiryDateTime((new DateTime())->add($this->refreshTokenTTL));
        }


        while ($maxGenerationAttempts-- > 0) {
            $refreshToken->setIdentifier($this->generateUniqueIdentifier());
            try {
                $this->refreshTokenRepository->persistNewRefreshToken($refreshToken);

                return $refreshToken;
            } catch (UniqueTokenIdentifierConstraintViolationException $e) {
                if ($maxGenerationAttempts === 0) {
                    throw $e;
                }
            }
        }
    }
700847
public function persistNewAccessToken(AccessTokenEntityInterface $accessTokenEntity)
    {
        $this->getEntityManager()->transactional(function(EntityManagerInterface $em) use ($accessTokenEntity) {
            $em->persist($accessTokenEntity);
        });
    }
932784
public static function createFromAccessTokenEntity(TokenInterface $accessTokenEntity)
    {
        $roles[] = 'ROLE_USER';
        if (($client = $accessTokenEntity->getClient()) instanceof ApiClientInterface ) {
            $roles = array_merge($roles, $client->getRoles());
        }

        if ($user = $accessTokenEntity->getUser()) {
            if ($user instanceof UserInterface) {
                $roles[] = 'ROLE_REAL_USER';
            }

            $roles = array_merge($roles, $user->getRoles());
        }
        $roles = array_unique($roles);

        $token = new self($roles);

        if ($user) {
            $token->setUser($user);
        }

        $token->setAuthenticated(true);
        $token->setAccessToken($accessTokenEntity->getCode());

        return $token;
    }
531576
public Credential refreshCredential(Credential credential) throws IOException {
    if (isCredentialRefreshable(credential)) {
      if (!callRefreshToken(credential)) {
        libLogger.warn("OAuth2 token could not be refreshed. "
            + "Add a refreshListener to the Credential to capture this failure.");
      }
    }
    return credential;
  }