This method returns the user id retrieved from jwt token data attached to
    the current flask app's context
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
1221318
def _FormatIPCPermToken(self, token_data):
    
    return {
        'user_id': token_data.user_identifier,
        'group_id': token_data.group_identifier,
        'creator_user_id': token_data.creator_user_identifier,
        'creator_group_id': token_data.creator_group_identifier,
        'access': token_data.access_mode}
1166685
async def _get_user_id(self, user, *, asdict=False):
        
        uid = self.config.user_id()
        if isinstance(user, dict):
            user_id = user.get(uid)
        elif hasattr(user, "to_dict"):
            _to_dict = await utils.call(user.to_dict)
            user_id = _to_dict.get(uid)
        else:
            raise exceptions.InvalidRetrieveUserObject()

        if asdict:
            return {uid: user_id}

        return user_id
825557
function getUserProfile(callback) {
    if (_.isUndefined(callback)) {
    } else {
      var u = baseUrl + "/me";
      var tokenData = this.getAuthToken();
      if (tokenData.type != "bearer") {
        throw new Error("Invalid token type. Must use a token of type bearer.");
      }
      return helper.get(tokenData, u, callback);
    }
  }
410941
def jwt_get_secret_key(payload=None):
    
    User = get_user_model()  # noqa
    if api_settings.JWT_GET_USER_SECRET_KEY:
        user = User.objects.get(pk=payload.get('user_id'))
        key = str(api_settings.JWT_GET_USER_SECRET_KEY(user))
        return key

    return api_settings.JWT_SECRET_KEY
877849
def get_token(self):
        
        if self.token == None:
            self.token = self.authenticate(self.username, self.password)
        try:
            return str(self.token,'utf-8')
        except TypeError:
            return self.token
780288
def users_feature(app):
    

    # check we have jwt secret configures
    if not app.config.get('USER_JWT_SECRET', None):
        raise x.JwtSecretMissing('Please set USER_JWT_SECRET in config')

    # use custom session interface
    app.session_interface = BoilerSessionInterface()

    # init user service
    user_service.init(app)

    # init login manager
    login_manager.init_app(app)
    login_manager.login_view = 'user.login'
    login_manager.login_message = None

    @login_manager.user_loader
    def load_user(id):
        return user_service.get(id)

    # init OAuth
    oauth.init_app(app)
    registry = OauthProviders(app)
    providers = registry.get_providers()
    with app.app_context():
        for provider in providers:
            if provider not in oauth.remote_apps:
                oauth.remote_app(provider, **providers[provider])
                registry.register_token_getter(provider)

    # init principal
    principal.init_app(app)

    @principal.identity_loader
    def load_identity():
        if current_user.is_authenticated:
            return Identity(current_user.id)
        session.pop('identity.name', None)
        session.pop('identity.auth_type', None)
        return AnonymousIdentity()

    @identity_loaded.connect_via(app)
    def on_identity_loaded(sender, identity):
        identity.user = current_user
        if not current_user.is_authenticated:
            return

        identity.provides.add(UserNeed(current_user.id))
        for role in current_user.roles:
            identity.provides.add(RoleNeed(role.handle))
1360817
def __get_logged_in_id(self):
        
        if self.__logged_in_id == None:
            self.__logged_in_id = self.account_verify_credentials().id
        return self.__logged_in_id
295300
def login():
    
    req = flask.request.get_json(force=True)
    username = req.get('username', None)
    password = req.get('password', None)
    user = guard.authenticate(username, password)
    ret = {'access_token': guard.encode_jwt_token(user)}
    return (flask.jsonify(ret), 200)
1284545
public function user()
    {
        // If we've already retrieved the user for the current request we can just
        // return it back immediately. We do not want to fetch the user data on
        // every call to this method because that would be tremendously slow.
        if (! is_null($this->user)) {
            return $this->user;
        }

        $user = null;

        // If a user ID was provided in the JWT, then
        // we should attempt to fetch their profile.
        if (! empty($this->id())) {
            $user = $this->provider->retrieveById($this->id());
        }

        return $this->user = $user;
    }
775483
function getUserForToken(decodedToken) {
        var userId = decodedToken._id;
        var authToken = decodedToken.authToken;
        var cacheKey = userId + authToken;
        var conditions = {
            caller: userService.admin,
            where: { _id: userId, authToken: authToken, status: 'created' },
            findOne: true
        };
        var cachedUser;

        // if no user id or authToken, then no user
        if (!userId || !authToken) { return null; }

        // try to get user from cache, then DB
        return userCacheService.get({ key: cacheKey })
            .then(function (user) {
                cachedUser = user;
                return user ? user : userService.find(conditions);
            })
            .then(function (user) {

                // if user found in database, but not in cache, save in cache
                if (user && !cachedUser) {
                    userCacheService.set({ key: cacheKey, value: user });
                }

                // return the user
                return user;
            });
    }
481395
def get_user_id(self, user):
        
        user_field = getattr(settings, 'SAML_IDP_DJANGO_USERNAME_FIELD', None) or \
                     getattr(user, 'USERNAME_FIELD', 'username')
        return str(getattr(user, user_field))
1245283
public function getUserId() {
    if (array_key_exists(self::USER_ATTR, $this->payload)) {
      return $this->payload[self::USER_ATTR];
    }
    throw new AuthException("No user_id in token");
  }
139404
def get_user(id=None, username=None, email=None, federated_id=None, provider=None, jwt=None):
    
    if id:
        return _user(models.AuthUser.get(id))
    elif username:
        return _user(models.AuthUser.get_by_username(username))
    elif email:
        return _user(models.AuthUser.get_by_email(email))
    elif federated_id and provider:
        user = models.AuthUserFederation.get_user(provider, federated_id)
        return _user(user) if user else None
    elif jwt:
        pass
561760
def client_id_from_id_token(id_token):
    
    payload = JWT().unpack(id_token).payload()
    aud = payload.get('aud', None)
    if aud is None:
        return None
    if isinstance(aud, list):
        return aud[0]
    return aud
58172
def verify_jwt_in_request():
    
    if request.method not in config.exempt_methods:
        jwt_data = _decode_jwt_from_request(request_type='access')
        ctx_stack.top.jwt = jwt_data
        verify_token_claims(jwt_data)
        _load_user(jwt_data[config.identity_claim_key])
991059
def getAuthenticatedUser(self, headers=None, query_params=None, content_type="application/json"):
        
        uri = self.client.base_url + "/self"
        return self.client.get(uri, None, headers, query_params, content_type)