Return the issuer in which this user's token was created
494336
def get_token_issuer():
    """"""
    try:
        current_user = stack.top.current_user
        return current_user.get('iss', get_config().jwt_issuer)
    except Exception:
        pass
    return get_config().jwt_issuer
985876
def access_token(self):
        """"""
        if self.user_id:
            return RemoteToken.get(
                self.user_id, self.remote.consumer_key
            ).access_token
        return self.remote.get_request_token()[0]
804626
def get_delegation_token(self, token_owner, renewer_kerberos_principal_name):
    
    self.send_get_delegation_token(token_owner, renewer_kerberos_principal_name)
    return self.recv_get_delegation_token()
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
814144
def get_user_token(self, scope, code=None):
        """"""

        user_token = self.__get_user_token(scope)

        if user_token:
            return user_token

        if self.__cache is not None:
            token = self.__cache.get(self.__user_token_cache_key())
            if token:
                return token

        if self.__redirect_uri is None or code is None:
            raise MxitAPIParameterException()

        self.__user_token = None

        payload = {
            'grant_type': 'authorization_code',
            'code': code,
            'redirect_uri': self.__redirect_uri
        }

        url = settings.AUTH_ENDPOINT + '/token'
        r = post(url, data=payload, auth=HTTPBasicAuth(self.__client_id, self.__client_secret), verify=self.__verify_cert)
        if r.status_code == 200:
            data = r.json()
            self.__set_user_token(scope, data[u'access_token'])
            if self.__cache is not None:
                self.__cache.set(self.__user_token_cache_key(scope), str(data[u'access_token']),
                                 data[u'expires_in'] - 300)

        user_token = self.__get_user_token(scope)

        if not user_token:
            raise MxitAPIException("Failed to retrieve user token for '%s' scope" % scope)

        return user_token
784076
def get_token(self):
        """"""
        auth_resp = self.get_auth()

        if auth_resp['status'] == 'mfa_req':
            token_resp = self.get_mfa(auth_resp)
        else:
            token_resp = auth_resp

        token = token_resp['data']['client_token']['client_token']
        return token
504314
def auth_string(self):
        
        if not self._token:
            self.execute()

        if not self._token.expired:
            return 'Bearer {}'.format(self._token.access_token)

        if self.auto_refresh:
            self.execute()
            return 'Bearer {}'.format(self._token.access_token)

        raise TokenExpired()
46254
def issuer(self, value):
        

        is_oscrypto = isinstance(value, asymmetric.Certificate)
        if not isinstance(value, x509.Certificate) and not is_oscrypto:
            raise TypeError(_pretty_message(
                '''
                issuer must be an instance of asn1crypto.x509.Certificate or
                oscrypto.asymmetric.Certificate, not %s
                ''',
                _type_name(value)
            ))

        if is_oscrypto:
            value = value.asn1

        self._issuer = value.subject

        self._key_identifier = self._subject_public_key.sha1
        self._authority_key_identifier = x509.AuthorityKeyIdentifier({
            'key_identifier': value.public_key.sha1
        })
322924
def current_user_id():
    
    jwt_data = get_jwt_data_from_app_context()
    user_id = jwt_data.get('id')
    PraetorianError.require_condition(
        user_id is not None,
        "Could not fetch an id for the current user",
    )
    return user_id
1201830
def verify_token(token, issuer:, audience:, client_id:)
      header, payload = token.split('.').first(2).map{|encoded| JSON.parse(Base64.decode64(encoded))}

      # validate claims
      raise InvalidToken.new('Invalid issuer')    if payload['iss'] != issuer
      raise InvalidToken.new('Invalid audience')  if payload['aud'] != audience
      raise InvalidToken.new('Invalid client')    if !Array(client_id).include?(payload['cid'])
      raise InvalidToken.new('Token is expired')  if payload['exp'].to_i <= Time.now.to_i

      # validate signature
      jwk = JSON::JWK.new(get_jwk(header, payload))
      JSON::JWT.decode(token, jwk.to_key)
    end
585958
def get_issuer(site_url=None, request=None):
    
    site_url = get_site_url(site_url=site_url, request=request)
    path = reverse('oidc_provider:provider-info') \
        .split('/.well-known/openid-configuration')[0]
    issuer = site_url + path

    return str(issuer)
26138
def find_for_provider(token, provider)
      return nil unless token['uid']
      props = {:uid => token['uid'].downcase, provider: provider.downcase}
      user = where(props).first
      # create new user if necessary
      unless user
        user = create!(whitelist(props))
        # can we add groups or roles here?
      end
      user
    end
540019
def token(self):
        
        if not self._token:
            self._token = self.fetch_token()
            logger.payment(self)
        return self._token
906561
def token(self):
        '''
        '''
        auth_header = self.headers.get('Authorization', '')
        if 'Token ' in auth_header:
            return auth_header.partition('Token ')[-1]
        else:
            return auth_header
384536
def get_signed_in_token(self):
        
        response = self._send(http_method='GET',
                              location_id='6074ff18-aaad-4abb-a41e-5c75f6178057',
                              version='5.0-preview.1')
        return self._deserialize('AccessTokenResult', response)
1346776
def get_logged_in_account(token_manager=None,
                          app_url=defaults.APP_URL):
    
    return get_logged_in_account(token_manager=token_manager,
                                 app_url=app_url)['id']
170781
function findExternalOrigin(issuer) {
  if (!_.isNil(issuer) && _.startsWith(issuer.rawRequest, './')) {
    return findExternalOrigin(issuer.issuer);
  }
  return issuer;
}