Gains token from secure backend service.

        :return: Token formatted for Cocaine protocol header.
438967
def fetch_token(self):
        
        grant_type = 'client_credentials'

        channel = yield self._tvm.ticket_full(
            self._client_id, self._client_secret, grant_type, {})
        ticket = yield channel.rx.get()

        raise gen.Return(self._make_token(ticket))
1018030
def client_tokens(self):
        
        client_id, client_secret = self.get_auth_basic()
        if not client_id and not client_secret:
            client_id = self.query_kwargs.get('client_id', '')
            client_secret = self.query_kwargs.get('client_secret', '')
            if not client_id and not client_secret:
                client_id = self.body_kwargs.get('client_id', '')
                client_secret = self.body_kwargs.get('client_secret', '')

        return client_id, client_secret
1311790
def _data_to_sign(self) -> bytes:
        
        packed = pack_reward_proof(
            canonical_identifier=CanonicalIdentifier(
                chain_identifier=self.balance_proof.chain_id,
                token_network_address=self.balance_proof.token_network_address,
                channel_identifier=self.balance_proof.channel_identifier,
            ),
            reward_amount=self.reward_amount,
            nonce=self.balance_proof.nonce,
        )
        return packed
252396
def get_token_from_header(request):
    
    token = None

    if 'Authorization' in request.headers:
        split_header = request.headers.get('Authorization').split()
        if len(split_header) == 2 and split_header[0] == 'Bearer':
            token = split_header[1]
    else:
        token = request.access_token

    return token
459723
def _obtain_api_token(self, username, password):
        """"""
        data = self._request("POST", "auth/apitoken",
                             {"username": username, "password": password},
                             reestablish_session=False)
        return data["api_token"]
1373643
def get_token(self, code, headers=None, **kwargs):
        
        self._check_configuration("site", "token_url", "redirect_uri",
                                  "client_id", "client_secret")
        url = "%s%s" % (self.site, quote(self.token_url))
        data = {
            'redirect_uri': self.redirect_uri,
            'client_id': self.client_id,
            'client_secret': self.client_secret,
            'code': code,
        }
        data.update(kwargs)

        return self._make_request(url, data=data, headers=headers)
450111
def get_token(self, body, params=None):
        
        if body in SKIP_IN_PATH:
            raise ValueError("Empty value passed for a required argument 'body'.")
        return self.transport.perform_request(
            "POST", "/_security/oauth2/token", params=params, body=body
        )
1050105
def get_token(self):
        
        if not self.authenticated:
            raise ValueError("Must authenticate() as a client first.")

        # If token has expired we'll need to refresh and get a new
        # client credential
        if self.is_expired_token(self.client):
            logging.info("client token expired, will need to refresh token")
            self.authenticate(self.client['id'], self.client['secret'],
                    use_cache=False)

        return self.client['access_token']
547205
def get_provider_token(self, provider_secret):
        
        return self._post(
            'service/get_provider_token',
            data={
                'corpid': self._client.corp_id,
                'provider_secret': provider_secret,
            }
        )
811093
def _get_concealed_token(self, token):
        
        enc_key = "%s:%s:%s" % (HASH_PATH_PREFIX, token, HASH_PATH_SUFFIX)
        return sha512(enc_key).hexdigest()
562810
def token(self):
        
        if self._token is None or \
           datetime.datetime.now() >= self._token_expires_on:
            if self._referer_url is None:
                self._generateForTokenSecurity(username=self._username,
                                           password=self._password,
                                           tokenUrl=self._token_url)
            else:
                self._generateForTokenSecurity(username=self._username,
                                               password=self._password,
                                               tokenUrl=self._token_url,
                                               client="referer")
        return self._token
1200606
def get_token(required_role: Roles::PUBLIC)
        token = params[:token]

        # Look up the cache. If present, use it and skip the verification.
        # Use token itself (and not a session UUID) as part of the key so
        # it can be considered *verified*.
        @auth_session = Cache.get(kind: :session, token: token)

        # Cache miss. So proceed to verify the token and get user and
        # session data from database. Then set the cache for later.
        if @auth_session.nil?
          @auth_session = verify_token(token)
          @auth_session.role  # NOTE: no-op
          Cache.set({kind: :session, token: token}, @auth_session)
        end

        # Obtained session may not have enough permission. Check here.
        if @auth_session.role < required_role
          logger.error("Not enough permission (role: #{@auth_session.role})")
          raise UNAUTHORIZED_ERROR, "Invalid token"
        end
        @auth_user = @auth_session.user
        @token = @auth_session.token
        return true
      end
265719
def request_access_token(self, params):
        
        return self.request(self.access_token_url, method="POST", params=params,
            is_signed=False)
152659
function get_jwt_token(ctx)
{
	// Parses "Authorization: Bearer ${token}"
	if (ctx.header.authorization)
	{
		const match = ctx.header.authorization.match(/^Bearer (.+)$/i)

		if (match)
		{
			return match[1]
		}
	}

	// (doesn't read cookies anymore to protect users from CSRF attacks)
	// // Tries the "authentication" cookie
	// if (ctx.cookies.get('authentication'))
	// {
	// 	return ctx.cookies.get('authentication')
	// }
}
1248110
def token(self):
        '''
        
        '''
        # find the token (cookie or headers)
        if AUTH_TOKEN_HEADER in self.request.headers:
            return self.request.headers[AUTH_TOKEN_HEADER]
        else:
            return self.get_cookie(AUTH_COOKIE_NAME)
1145197
def token(self):
        
        if self._token is None or \
           datetime.datetime.now() >= self._token_expires_on:
            if self._referer_url is None:
                result = self._generateForTokenSecurity(username=self._username,
                                                    password=self._password,
                                                    tokenUrl=self._token_url)
            else:
                result = self._generateForTokenSecurity(username=self._username,
                                                        password=self._password,
                                                        tokenUrl=self._token_url,
                                                        client="referer")
            if 'error' in result:
                self._valid = False
                self._message = result
            else:
                self._valid = True
                self._message = "Token Generated"
        return self._token
840672
async def _get_security_token(self) -> None:
        """"""
        _LOGGER.debug('Requesting security token.')
        if self._credentials is None:
            return

        # Make sure only 1 request can be sent at a time.
        async with self._security_token_lock:
            # Confirm there is still no security token.
            if self._security_token is None:
                login_resp = await self._request(
                    'post',
                    LOGIN_ENDPOINT,
                    json=self._credentials,
                    login_request=True,
                )

                return_code = int(login_resp.get('ReturnCode', 1))
                if return_code != 0:
                    if return_code == 203:
                        # Invalid username or password.
                        _LOGGER.debug('Invalid username or password')
                        self._credentials = None
                    raise MyQError(login_resp['ErrorMessage'])

                self._security_token = login_resp['SecurityToken']