Set the token for the v20 context

        Args:
            token: The token used to access the v20 REST api
167581
def set_token(self, token):
        

        self.token = token

        self.set_header(
            'Authorization',
            "Bearer {}".format(token)
        )
929868
def request_token(self) -> None:
        
        response: requests.Response = requests.post(
            self._TOKEN_URL,
            auth=HTTPBasicAuth(self._client_id, self._client_key),
            data={"grant_type": self._GRANT_TYPE},
            verify=True
        )
        response.raise_for_status()
        self._token = response.json()
        self._token_expires_at = time.time() + self._token["expires_in"]
536160
def token(self, token):
        
        self._token = token
        if token:
            self.current_user = self.query_login_user()
1071221
def set_request_defaults(endpoint, private_token, sudo=nil)
      raise Error::MissingCredentials.new("Please set an endpoint to API") unless endpoint
      @private_token = private_token

      self.class.base_uri endpoint
      self.class.default_params :sudo => sudo
      self.class.default_params.delete(:sudo) if sudo.nil?
    end
485584
def save_token(self, token, request, *args, **kwargs):
        
        return self.save_bearer_token(token, request, *args, **kwargs)
687487
def api_token_header(options, path = nil)
      return nil if path == '/j_security_check'
      unless @api_token
        fail Error::MissingCredentials, 'Please set a api_token for user'
      end
      options[:headers] = {} if options[:headers].nil?
      options[:headers].merge!('X-Rundeck-Auth-Token' => @api_token)
    end
1141253
def refresh_token(self, headers=None, **kwargs):
        
        self._check_configuration("site", "token_url", "client_id",
                                  "client_secret")
        url = "%s%s" % (self.site, quote(self.token_url))
        data = {
            'client_id': self.client_id,
            'client_secret': self.client_secret,
        }
        data.update(kwargs)

        return self._make_request(url, data=data, headers=headers)
554393
def token_middleware(ctx, get_response):
    
    async def middleware(request):
        params = request.setdefault('params', {})
        if params.get("token") is None:
            params['token'] = ctx.token
        return await get_response(request)
    return middleware
61209
def _update_token(self, request):
        

        # Refresh our source credentials.
        self._source_credentials.refresh(request)

        body = {
            "delegates": self._delegates,
            "scope": self._target_scopes,
            "lifetime": str(self._lifetime) + "s"
        }

        headers = {
            'Content-Type': 'application/json',
        }

        # Apply the source credentials authentication info.
        self._source_credentials.apply(headers)

        self.token, self.expiry = _make_iam_token_request(
            request=request,
            principal=self._target_principal,
            headers=headers,
            body=body)
1344090
def setup_client(token)
      client = Octokit::Client.new(access_token: token)
      client.auto_paginate = true
      client
    end
1089883
def _set_token(self):
        """"""
        try:
            self.token = os.environ['CERBERUS_TOKEN']
            if self.verbose:
                print("Overriding Cerberus token with environment variable.", file=sys.stderr)
            logger.info("Overriding Cerberus token with environment variable.")
            return
        except:
            pass
        if self.username:
            ua = UserAuth(self.cerberus_url, self.username, self.password)
            self.token = ua.get_token()
        else:
            awsa = AWSAuth(self.cerberus_url, region=self.region, aws_session=self.aws_session, verbose=self.verbose)
            self.token = awsa.get_token()
27068
def set(parser, token):
    
    bits = token.contents.split(' ')[1:]
    new_token = Token(TOKEN_BLOCK, ' '.join(bits[:-1]))
    if bits[0] in parser.tags:
        func = parser.tags[bits[0]](parser, new_token)
    else:
        func = Variable(bits[0])
    return SetNode(func, bits[-1])
242133
def resource_set_read(self, token, id):
        
        return self._realm.client.get(
            '{}/{}'.format(
                self.well_known['resource_registration_endpoint'], id),
            headers=self.get_headers(token)
        )
154107
def refresh_token(self, refresh_token, **kwargs):
        
        return self._token_request(grant_type='refresh_token',
                                   refresh_token=refresh_token, **kwargs)
450349
def create_token(credential, opts = {})
      data, _status_code, _headers = create_token_with_http_info(credential, opts)
      return data
    end
97891
def update_token(self):
        
        if not self.username or not self.password:
            raise errors.TokenExpired("Unable to refresh token - no username or password.")
        encoded_uri = compat.quote_plus(self.uri).encode(self._encoding)  # pylint: disable=no-member
        encoded_key = compat.quote_plus(self.username).encode(self._encoding)  # pylint: disable=no-member
        self.expires_at = time.time() + self.expires_in.seconds
        self.token = utils.create_sas_token(
            encoded_key,
            self.password.encode(self._encoding),
            encoded_uri,
            self.expires_in)
89036
def add_token(self, token_identifier, delegation_token):
    
    self.send_add_token(token_identifier, delegation_token)
    return self.recv_add_token()