Creates an refresh token bound to the specified access token.
516920
def create_refresh_token(self, access_token_value):
        # type: (str) -> str
        
        if access_token_value not in self.access_tokens:
            raise InvalidAccessToken('{} unknown'.format(access_token_value))

        if not self.refresh_token_lifetime:
            logger.debug('no refresh token issued for for access_token=%s', access_token_value)
            return None

        refresh_token = rand_str()
        authz_info = {'access_token': access_token_value, 'exp': int(time.time()) + self.refresh_token_lifetime}
        self.refresh_tokens[refresh_token] = authz_info

        logger.debug('issued refresh_token=%s expiring=%d for access_token=%s', refresh_token, authz_info['exp'],
                     access_token_value)
        return refresh_token
982543
AuthenticationResult acquireAccessTokenFromRefreshToken(String resource, String refreshToken, boolean isMultipleResourceRefreshToken) throws IOException {
        ExecutorService executor = Executors.newSingleThreadExecutor();
        try {
            return refreshTokenClient.refreshToken(domain(), clientId(), resource, refreshToken, isMultipleResourceRefreshToken);
        } catch (Exception e) {
            return null;
        } finally {
            executor.shutdown();
        }
    }
264602
def save_token(self, access_token):
        
        self.access_tokens[access_token.token] = access_token

        unique_token_key = self._unique_token_key(access_token.client_id,
                                                  access_token.grant_type,
                                                  access_token.user_id)

        self.unique_token_identifier[unique_token_key] = access_token.token

        if access_token.refresh_token is not None:
            self.refresh_tokens[access_token.refresh_token] = access_token

        return True
703044
def refresh_token(self):
        
        self.token = self.oauth.refresh_token(self.access_token_url, refresh_token=self.get_refresh_token())
        self.access_token = self.token.get("access_token")
393121
private function refreshAccessToken(Provider $provider, $userId, AccessToken $accessToken)
    {
        // prepare access_token request
        $tokenRequestData = [
            'grant_type' => 'refresh_token',
            'refresh_token' => $accessToken->getRefreshToken(),
            'scope' => $accessToken->getScope(),
        ];

        $response = $this->httpClient->send(
            Request::post(
                $provider->getTokenEndpoint(),
                $tokenRequestData,
                self::getAuthorizationHeader(
                    $provider->getClientId(),
                    $provider->getSecret()
                )
            )
        );

        if (false === $response->isOkay()) {
            $responseData = $response->json();
            if (\array_key_exists('error', $responseData) && 'invalid_grant' === $responseData['error']) {
                // delete the access_token, we assume the user revoked it, that
                // is why we get "invalid_grant"
                $this->tokenStorage->deleteAccessToken($userId, $accessToken);

                return false;
            }

            throw new TokenException('unable to refresh access_token', $response);
        }

        // delete old AccessToken as we'll write a new one anyway...
        $this->tokenStorage->deleteAccessToken($userId, $accessToken);

        $accessToken = AccessToken::fromRefreshResponse(
            $provider,
            $this->dateTime,
            $response->json(),
            // provide the old AccessToken to borrow some fields if the server
            // does not provide them on "refresh"
            $accessToken
        );

        // store the refreshed AccessToken
        $this->tokenStorage->storeAccessToken($userId, $accessToken);

        return $accessToken;
    }
719295
def refresh_token(self, refresh_token):
        

        response = requests.post('%saccess_token' % OAUTH_URL, {
                                 'refresh_token': refresh_token,
                                 'grant_type': 'refresh_token',
                                 'client_id': self.client_id,
                                 'client_secret': self.client_secret
                                 })
        resp = json.loads(response.content)

        if 'access_token' in resp:
            self.token = resp['access_token']

        return resp
1221812
def generate_access_token_from_refresh_token(request, client):
  
  refresh_token_value = request.POST.get('refresh_token')
  if not refresh_token_value:
    raise InvalidRequest('no "refresh_token" provided')

  try:
    existing_access_token = AccessToken.objects.get(
        refresh_token=refresh_token_value,
        client=client)
  except AccessToken.DoesNotExist:
    raise InvalidGrant('"{}" is not a valid "refresh_token"'.format(
      refresh_token_value))

  if existing_access_token.invalidated:
    refresh_token_used_after_invalidation.send(
        sender='djoauth2',
        access_token=existing_access_token,
        request=request)
    raise InvalidGrant('"{}" is not a valid "refresh_token"'.format(
      refresh_token_value))

  if not existing_access_token.refreshable:
    raise InvalidGrant('access token is not refreshable')

  # The specification (http://tools.ietf.org/html/rfc6749#section-6) describes
  # the scope parameter as follows:
  #
  #     scope
  #           OPTIONAL.  The scope of the access request as described by
  #           Section 3.3.  The requested scope MUST NOT include any
  #           scope not originally granted by the resource owner, and if
  #           omitted is treated as equal to the scope originally granted
  #           by the resource owner.
  #
  # This opens the possibility that a Client might successfully request a
  # subset of the existing scopes, but later in the same section comes the
  # following:
  #
  #      If a new refresh token is issued, the refresh token scope MUST be
  #      identical to that of the refresh token included by the client in the
  #      request.
  #
  # Confusingly, http://tools.ietf.org/html/rfc6749#section-1.5 includes the
  # following:
  #
  #     Refresh tokens are credentials used to obtain access tokens.  Refresh
  #     tokens are issued to the client by the authorization server and are
  #     used to obtain a new access token when the current access token becomes
  #     invalid or expires, or to obtain additional access tokens with
  #     identical or narrower scope (access tokens may have a shorter lifetime
  #     and fewer permissions than authorized by the resource owner).
  #
  # This last section explicitly allows tokens with narrower scope than
  # originally granted, which is in direct contradiction with the directive
  # that the scope must be equivalent to that granted earlier.
  #
  # Because the specification seems to contradict itself, I tend towards
  # observing the stricter directive (not allowing a subset of scope,) even
  # though to me there seems to be no reason to disallow that feature. That
  # said, I'm not sure why a client would ever ask for less scope than
  # originally granted.
  scope_objects = existing_access_token.scopes.all()
  new_scope_names = request.POST.get('scope', '')
  if new_scope_names:
    new_scope_names = new_scope_names.split(' ')
    if not existing_access_token.has_scope(*new_scope_names):
      raise InvalidScope('requested scopes exceed initial grant')

    scope_objects = []
    for scope_name in new_scope_names:
      try:
        scope_objects.append(Scope.objects.get(name=scope_name))
      except Scope.DoesNotExist:
        raise InvalidScope('"{}" is not a valid scope'.format(scope_name))

  requested_scope_string = request.POST.get('scope', '')
  if requested_scope_string:
    requested_scope_names = set(requested_scope_string.split(' '))
    if not requested_scope_names == existing_access_token.get_scope_names_set():
      raise InvalidScope('requested scopes do not match initial grant')


  # The new AccessToken is only refreshable if at the time of refresh the
  # server is configured to create refreshable tokens by default. It DOES NOT
  # inherit the existing token's 'refreshability' automatically. No behavior is
  # described in the specification; I believe this to be a sane decision.
  new_access_token = AccessToken.objects.create(
      user=existing_access_token.user,
      client=existing_access_token.client)
  new_access_token.authorization_code = existing_access_token.authorization_code
  new_access_token.scopes = scope_objects
  new_access_token.save()

  existing_access_token.invalidate()

  return new_access_token
53617
public function refresh()
    {
        $query = [
            'appid' => $this->appid,
            'grant_type' => 'refresh_token',
            'refresh_token' => $this['refresh_token'],
        ];

        $response = Http::request('GET', static::REFRESH)
            ->withQuery($query)
            ->send();

        if (0 != $response['errcode']) {
            throw new \Exception($response['errmsg'], $response['errcode']);
        }

        // update new access_token from ArrayCollection
        parent::__construct($response->toArray());

        return $this;
    }
115364
def _refresh_token_flow(self):
        """"""
        url = '%s%s/oauth2/token' % (self.scheme, self.host)
        options = {
            'grant_type': 'refresh_token',
            'client_id': self.options.get('client_id'),
            'client_secret': self.options.get('client_secret'),
            'refresh_token': self.options.get('refresh_token')
        }
        options.update({
            'verify_ssl': self.options.get('verify_ssl', True),
            'proxies': self.options.get('proxies', None)
        })
        self.token = wrapped_resource(
            make_request('post', url, options))
        self.access_token = self.token.access_token
961818
public synchronized void refreshToken()
	{
		final String refreshToken = this.response.refresh_token;

		this.response = null;
		this.cachedInfo = null;

		final String responseStr = authService.getToken(UserManagerOAuthService.GRANT_TYPE_REFRESH_TOKEN,
		                                                null,
		                                                null,
		                                                clientId,
		                                                clientSecret,
		                                                refreshToken,
		                                                null,
		                                                null,
		                                                null);

		loadAuthResponse(responseStr);
	}
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');
        }
    }
787964
public Response<AccessTokenDetails> refreshAccessToken(final String refreshToken) throws FreesoundClientException {
		final RefreshOAuth2AccessTokenRequest tokenRequest =
				new RefreshOAuth2AccessTokenRequest(clientId, clientSecret, refreshToken);

		return executeQuery(tokenRequest);
	}
395435
def refresh(self):
        """"""
        if self.refresh_token is None:
            raise InvalidInvocation("refresh token not provided")
        self._request_token(
            grant_type="refresh_token", refresh_token=self.refresh_token
        )
665279
public Credential setRefreshToken(String refreshToken) {
    lock.lock();
    try {
      if (refreshToken != null) {
        Preconditions.checkArgument(jsonFactory != null && transport != null
            && clientAuthentication != null && tokenServerEncodedUrl != null,
            "Please use the Builder and call setJsonFactory, setTransport, setClientAuthentication"
            + " and setTokenServerUrl/setTokenServerEncodedUrl");
      }
      this.refreshToken = refreshToken;
    } finally {
      lock.unlock();
    }
    return this;
  }
1202283
def refresh_token!(refresh_token)
      old_token = OAuth2::AccessToken.new(oauth_client,'', refresh_token: refresh_token)
      self.access_token = old_token.refresh!
    end
90798
def _refresh(self, _):
        
        # pylint: disable=import-error
        from google.appengine.api import app_identity
        try:
            token, _ = app_identity.get_access_token(self._scopes)
        except app_identity.Error as e:
            raise exceptions.CredentialsError(str(e))
        self.access_token = token
149171
BoxRefreshAuthRequest refreshOAuth(String refreshToken, String clientId, String clientSecret) {
        BoxRefreshAuthRequest request = new BoxRefreshAuthRequest(mSession, getTokenUrl(), refreshToken, clientId, clientSecret);
        return request;
    }