Calls /users/me route on campfire to get the authenticated user information, including token
174408
def authenticate(&callback)
      user("me") do |user|
        self.token = user.token
        callback.call(user)
      end
    end
75920
def get_user_info(user):
    
    user = api.get_user(user)
    current = api.get_current_user()

    if api.is_anonymous():
        return {
            "username": current.getUserName(),
            "authenticated": False,
            "roles": current.getRoles(),
            "api_url": api.url_for("plone.jsonapi.routes.users", username="current"),
        }

    # nothing to do
    if user is None:
        logger.warn("No user found for {}".format(user))
        return None

    # plone user
    pu = user.getUser()

    info = {
        "username": user.getUserName(),
        "roles": user.getRoles(),
        "groups": pu.getGroups(),
        "authenticated": current == user,
        "api_url": api.url_for("senaite.jsonapi.v1.users", username=user.getId()),
    }

    for k, v in api.get_user_properties(user).items():
        if api.is_date(v):
            v = api.to_iso_date(v)
        if not api.is_json_serializable(v):
            logger.warn("User property '{}' is not JSON serializable".format(k))
            continue
        info[k] = v

    return info
1256907
function processToken(token, done) {
    var user = _.find(users, function (item) {
        return item.username === token[claims.username];
    });
    if (!user) {
        user = {
            id          : token[claims.id] || currId++,
            username    : token[claims.username],
            email       : token[claims.email],
            firstName   : token[claims.firstName],
            lastName    : token[claims.lastName]
        };
        var roles = token[claims.role];
        if (!roles) {
            roles = ["guest"];
        } else if (!(roles instanceof Array)) {
            roles = [roles];
        }
        user.roles = roles;
        users.push(user);
    }
    done(null, user);
}
657040
def get_users(deployment_name,
              token_manager=None,
              app_url=defaults.APP_URL):
    
    deployment_id = get_deployment_id(deployment_name,
                                      token_manager=token_manager,
                                      app_url=app_url)

    headers = token_manager.get_access_token_headers()
    deployment_url = environment.get_deployment_url(app_url=app_url)
    response = requests.get('%s/api/v1/deployments/%s/accounts' %
                            (deployment_url, deployment_id),
                            headers=headers)

    if response.status_code == 200:
        return response.json()
    else:
        raise JutException('Error %s: %s' % (response.status_code, response.text))
456083
def log_user_in(app_id, token, ticket, response, cookie_name='user',
                url_detail='https://pswdless.appspot.com/rest/detail'):
    '''
    
    '''
    return LogUserIn(app_id, token, ticket, response, cookie_name, url_detail)
28308
def get_user_info(self):
        
        response = self.get_proto(path='/user')
        message = yamcsManagement_pb2.UserInfo()
        message.ParseFromString(response.content)
        return UserInfo(message)
1257769
def get_user(request):
    
    user = None
    try:
        user_id = request.session[SESSION_KEY]
        token = request.session[AUTH_TOKEN_SESSION_KEY]
        user_data = request.session[USER_DATA_SESSION_KEY]
        backend_path = request.session[BACKEND_SESSION_KEY]
    except KeyError:
        pass
    else:
        if backend_path in settings.AUTHENTICATION_BACKENDS:
            backend = load_backend(backend_path)
            user = backend.get_user(user_id, token, user_data)
            # Verify the session
            if hasattr(user, 'get_session_auth_hash'):
                session_hash = request.session.get(HASH_SESSION_KEY)
                session_hash_verified = session_hash and constant_time_compare(
                    session_hash,
                    user.get_session_auth_hash()
                )
                if not session_hash_verified:
                    request.session.flush()
                    user = None

    return user or MojAnonymousUser()
1125039
async function setUserInfo(auth) {
    try {
        const authenticated = await authWithFirebase(auth);
        const token = await firebase.auth().currentUser.getIdToken();
        const userId = firebase.auth().currentUser.uid;
        const userInfo = await getUserInfo(auth);
        userInfo.version = pjson.version;
        userInfo.lastLogin = {
            ".sv": "timestamp",
        };

        const infoUrl = `${constants.FIREBASE_DATABASE_URL}/users/${userId}.json?auth=${token}`;

        await request({
            url: infoUrl,
            method: "PATCH",
            json: true,
            headers: {
                "content-type": "application/json",
            },
            body: userInfo,
        });
        return true;
    } catch (err) {
        err.origin = 'setUserInfo';
        await error.log(err);
        return false;
    }
}
406095
def userinfo_request(self, access_token):
        
        http_method = self._provider_configuration.userinfo_endpoint_method
        if http_method is None or not self._client.userinfo_endpoint:
            return None

        logger.debug('making userinfo request')
        userinfo_response = self._client.do_user_info_request(method=http_method, token=access_token)
        logger.debug('received userinfo response: %s', userinfo_response.to_json())

        return userinfo_response
1227488
def get_authenticated_user(self, callback):
        
        self.require_setting(self._CLIENT_ID_SETTING, self._API_NAME)
        self.require_setting(self._CLIENT_SECRET_SETTING, self._API_NAME)

        if self.state:
            if (not self.get_argument('state', None) or
                self.state != self.get_argument('state')):
                LOGGER.error('State did not match: %s != %s',
                             self.state, self.get_argument('state'))
                raise auth.AuthError('Problematic Reply from %s' %
                                     self._API_NAME)

        args = {'client_id': self.settings[self._CLIENT_ID_SETTING],
                'client_secret': self.settings[self._CLIENT_SECRET_SETTING],
                'code': self.get_argument('code'),
                'redirect_uri': self.oauth2_redirect_uri()}

        http_client = self._get_auth_http_client()
        callback = self.async_callback(self._on_access_token, callback)
        http_client.fetch(self._OAUTH_ACCESS_TOKEN_URL,
                          method='POST',
                          headers={'Accept': self._ACCEPT},
                          user_agent=self._USER_AGENT,
                          body=auth.urllib_parse.urlencode(args),
                          callback=callback)
1218542
def authenticated(viewfunc):
    """"""
    @wraps(viewfunc)
    def wrapper(*args, **kwargs):
        ctx = stack.top
        if ctx and hasattr(ctx, 'htauth'):
            auth_header = request.headers.get('Authorization', None)
            if not auth_header:
                return _unauthorized_response()

            if not auth_header.startswith('Basic '):
                raise RuntimeError('Flask-HTAuth supports only Basic auth.')

            auth_header = auth_header.replace('Basic ', '')
            auth_header = base64.b64decode(auth_header)
            username, password = auth_header.split(':', 1)

            if not username in ctx.htauth['users']:
                return _unauthorized_response()

            if not check_password(password, ctx.htauth['users'][username]):
                return _unauthorized_response()

            g.htauth_user = username

        return viewfunc(*args, **kwargs)

    return wrapper
1233993
def fetch_user(app_id, token, ticket, url_detail='https://pswdless.appspot.com/rest/detail'):
    '''
    
    '''
    return FetchUserWithValidation(app_id, token, ticket, url_detail)
87179
async def get_me(self) -> types.User:
        
        payload = generate_payload(**locals())

        result = await self.request(api.Methods.GET_ME, payload)
        return types.User(**result)
1051383
def get_auth_token(self, user_payload):
        
        token = user_payload.get('token') or None
        if not token:
            raise ValueError('`user_payload` must provide api token')

        return '{auth_header_prefix} {token}'.format(
            auth_header_prefix=self.auth_header_prefix, token=token)
1086942
def get_user(self, key = None):
		'''
		''' 	
		if key:
			uri = self.api_uri + "/users/" + key
		else:
			uri = self.api_uri + "/users/me"

		return self._req('get', uri)
1244235
def authenticate(self):
        
        resp = self.session.get(self.api_url, auth=self.auth)
        resp = self._process_response(resp)
        return resp
744653
def get_request(self, request):
        """"""
        request.headers['authenticate'] = {
            'complexType': 'PortalLoginToken',
            'userId': self.user_id,
            'authToken': self.auth_token,
        }
        return request