If we are in an app context we can authenticate immediately.
436969
def _auto_authenticate(self):
        
        client_id = predix.config.get_env_value(predix.app.Manifest, 'client_id')
        client_secret = predix.config.get_env_value(predix.app.Manifest, 'client_secret')

        if client_id and client_secret:
            logging.info("Automatically authenticated as %s" % (client_id))
            self.uaa.authenticate(client_id, client_secret)
561721
def authenticate(self):
        
        basic_auth = request.authorization
        is_valid = False
        user = None
        if basic_auth:
            is_valid, user = self.check_basic_auth(
                basic_auth.username, basic_auth.password
            )
        else:  # Try token auth
            token = request.headers.get('Authorization', None)
            param_token = request.args.get('access_token')
            if token or param_token:
                if token:
                    # slice the 'token ' piece of the header (following
                    # github style):
                    token = token[6:]
                else:
                    # Grab it from query dict instead
                    token = param_token
                log.debug('Received token: %s', token)

                is_valid, user = self.check_token_auth(token)
        return (is_valid, user)
738639
def authenticated(function):
    """"""
    def wrapped(*args):
        """Wrap function."""
        try:
            return function(*args)
        except MoparError:
            _LOGGER.info("attempted to access page before login")
            _login(args[0])
            return function(*args)
    return wrapped
245414
def authenticate(self, user, password):
        """"""
        assert user['password_hash'] == '_'.join((password, 'hash'))
        self.logger.debug('User %s has been successfully authenticated',
                          user['uid'])
915867
def authenticate(self):
        ''''''

        if not hasattr(self, 'client'):
            self.client = uservoice.Client(self.subdomain,
                                           self.api_key,
                                           self.api_secret)
1341162
def authenticate_credentials(self, userid, password, request=None):
        """"""

        user = auth.authenticate(username=userid, password=password)

        if user is None or (user and not user.is_active):
            raise exceptions.AuthenticationFailed("Invalid username/password.")

        return (user, None)
1356184
def authenticate(self, bound_route, actual_params) -> bool:
        
        if self.__auth_service is not None:
            auth_route = "{0}_{1}{2}".format(self.__method, self.__route, bound_route)
            auth_data = self.__auth_service.authenticate(self.__request, auth_route, actual_params)
            if auth_data is True:
                self.app.auth_data = self.__auth_service.auth_data
            else:
                return False

        return True
478009
def _authenticate(self):
        """"""
        response = self._get("/v1/domains/{0}".format(self.domain))

        self.domain_id = response["domain"]["id"]
610038
def _verify_and_add_jwt():
    
    if not app_context_has_jwt_data():
        guard = current_guard()
        token = guard.read_token_from_header()
        jwt_data = guard.extract_jwt_token(token)
        add_jwt_data_to_app_context(jwt_data)
1058144
def authenticated(f):
    """"""
    @wraps(f)
    def new_f(self, *args, **kwargs):
        if not self.nova_client.client.auth_token:
            self.authenticate()
        return f(self, *args, **kwargs)
    return new_f
1327521
def login_generic(request, username, password):
        """"""
        user = authenticate(username=username, password=password)
        if user is not None and user.is_active:
            login(request, user)
            return True
        return False
843624
public void startAuthActivity(Context context, Bundle extras) {
        if (!startDelegateActivity(context, delegate.getAuthStartIntent(), extras)) {
            startActivity(context, extras, AuthActivity.class);
        }
    }
834246
function authenticateClient (req, res, next) {
  Client.authenticate(req, function (err, client) {
    if (err) { return next(err) }
    req.client = client
    next()
  })
}
366583
final protected function onAuth()
    {
        $authService = $this->getAuthService();

        $this->authManager->setAuthService($authService);

        if ($this->authActive === true) {
            if ($authService->isLoggedIn()) {
                $this->onSuccess();
            } else {
                $this->onFailure();
            }
        }

        // Now handle RBRAC if present
        if ($this->hasRbacRules()) {
            // Check if provided user has enough privileges
            if (!$this->hasRight($authService->getRole())) {
                $this->onNoRights();
            }
        }
    }
666650
protected boolean startAuthentication(final C context, final List<Client> currentClients) {
        return isNotEmpty(currentClients) && currentClients.get(0) instanceof IndirectClient;
    }
731900
public void authenticate(){
        if(fingerprintSecureCallback!=null){
            if(cryptoObject!=null){
                throw new RuntimeException("If you specify a CryptoObject you have to use FingerprintCallback");
            }
            cryptoObject = cipherHelper.getEncryptionCryptoObject();
            if(cryptoObject==null) {
                fingerprintSecureCallback.onNewFingerprintEnrolled(new FingerprintToken(cipherHelper));
            }
        }
        else if(fingerprintCallback==null){
            throw new RuntimeException("You must specify a callback.");
        }

        cancellationSignal = new CancellationSignal();
        if(fingerprintManager.isHardwareDetected() && fingerprintManager.hasEnrolledFingerprints()) {
            fingerprintManager.authenticate(cryptoObject, cancellationSignal, 0, new FingerprintManager.AuthenticationCallback() {
                @Override
                public void onAuthenticationError(int errorCode, CharSequence errString) {
                    super.onAuthenticationError(errorCode, errString);
                    setStatus(R.drawable.fingerprint_error, fingerprintError, circleError);
                    handler.postDelayed(returnToScanning, delayAfterError);
                    if(fingerprintSecureCallback!=null){
                        fingerprintSecureCallback.onAuthenticationError(errorCode, errString.toString());
                    } else{
                        fingerprintCallback.onAuthenticationError(errorCode, errString.toString());
                    }
                }

                @Override
                public void onAuthenticationHelp(int helpCode, CharSequence helpString) {
                    super.onAuthenticationHelp(helpCode, helpString);
                    setStatus(R.drawable.fingerprint_error, fingerprintError, circleError);
                    handler.postDelayed(returnToScanning, delayAfterError);
                    if(fingerprintSecureCallback!=null){
                        fingerprintSecureCallback.onAuthenticationError(helpCode, helpString.toString());
                    } else{
                        fingerprintCallback.onAuthenticationError(helpCode, helpString.toString());
                    }
                }

                @Override
                public void onAuthenticationSucceeded(final FingerprintManager.AuthenticationResult result) {
                    super.onAuthenticationSucceeded(result);
                    handler.removeCallbacks(returnToScanning);
                    setStatus(R.drawable.fingerprint_success, fingerprintSuccess, circleSuccess);
                    if(fingerprintSecureCallback!=null){
                        fingerprintSecureCallback.onAuthenticationSucceeded();
                    }
                    else{
                        fingerprintCallback.onAuthenticationSucceeded();
                    }
                    tryCounter = 0;
                }

                @Override
                public void onAuthenticationFailed() {
                    super.onAuthenticationFailed();
                    setStatus(R.drawable.fingerprint_error, fingerprintError, circleError);
                    handler.postDelayed(returnToScanning, delayAfterError);
                    handler.postDelayed(checkForLimit, delayAfterError);
                    if(fingerprintSecureCallback!=null){
                        fingerprintSecureCallback.onAuthenticationFailed();
                    }
                    else{
                        fingerprintCallback.onAuthenticationFailed();
                    }
                }
            }, null);
        }
        else{
            Log.e(TAG, "Fingerprint scanner not detected or no fingerprint enrolled. Use FingerprintView#isAvailable(Context) before.");
        }
    }
432720
async function authenticate(options) {
    const tokenFile = path.join(constants.GLOBAL_DIR, constants.GLOBAL_TOKEN);
    const configFile = path.join(constants.GLOBAL_DIR, constants.GLOBAL_CONFIG);

    // Ensure a config file exists
    if (!fs.pathExistsSync(configFile)) {
        createFile({
            name: configFile,
            source: `{}\n`,
        });
    }

    // Remove the token file if we are forcing reauth
    if (options.force) {
        fs.removeSync(tokenFile);
    }

    // get Oauth client
    const oauth2ClientResult = await getAuthClient();
    const oauth2Client = oauth2ClientResult.client;
    const isCustomClient = oauth2ClientResult.custom;
    let newOauth2Client;

    // Check if we have previously stored a token.
    let token;
    try {
        token = fs.readFileSync(tokenFile, 'utf8');
    } catch (err) {
        newOauth2Client = await getNewToken(oauth2Client, isCustomClient, options);
        await firebase.setUserInfo(newOauth2Client);
        return newOauth2Client;
    }

    // If we can find the token, refresh it, get a new one or do nothing
    const tokenObject = JSON.parse(token);
    oauth2Client.credentials = tokenObject;
    const ttl = oauth2Client.credentials.expiry_date - Date.now();

    if (ttl < 10 * 1000 || options.refresh) {
        try {
            newOauth2Client = await getToken(null, token, oauth2Client, isCustomClient);
            await firebase.setUserInfo(newOauth2Client);
            return newOauth2Client;
        } catch (err) {
            newOauth2Client = await getNewToken(oauth2Client, isCustomClient, options);
            await firebase.setUserInfo(newOauth2Client);
            return newOauth2Client;
        }
    } else {
        return oauth2Client;
    }
}