Set the authorize token for future requests for "Basic" authentication.
553542
@Override
    public void processAuthorize(WebSocketChannel channel, String authorizeToken) {
        LOG.entering(CLASS_NAME, "processAuthorize");

        WebSocketNativeChannel nativeChannel = (WebSocketNativeChannel)channel;
        Proxy proxy = nativeChannel.getProxy();
        proxy.processEvent(XoaEventKind.AUTHORIZE, new String[] { authorizeToken });
    }
688317
def _do_authorize(self):
        
        if self.auth_data is None:
            raise ApiwatcherClientException("You must provide authorization data.")

        r = requests.post(
            "{0}/api/token".format(self.base_url), json=self.auth_data,
            verify=self.verify_certificate, timeout=self.timeout
        )

        if r.status_code == 401:
            raise ApiwatcherClientException("Wrong credentials supplied: {0}".format(
                r.json()["message"]
            ))
        elif r.status_code != 201:
            try:
                reason = r.json()["message"]
            except:
                reason = r.text
            raise ApiwatcherClientException(
                "Authorization failed. Reason {0} {1}".format(
                    r.status_code, reason)
                )
        else:
            data = r.json()["data"]
            self.token = data["access_token"]

            if "refresh_token" in data:
                self.auth_data = {
                    "grant_type": "refresh_token",
                    "refresh_token": data["refresh_token"],
                    "client_id": self.auth_data["client_id"]
                }
1187067
public CLIConnectionFactory basicAuth(String userInfo) {
        return authorization("Basic " + new String(Base64.encodeBase64((userInfo).getBytes())));
    }
963113
def requires_basic_auth(f):
    """"""

    def check_auth(username, password):
        return username == "guest" and password == "secret"

    def authenticate():
        return Response(
            "Authentication required.", 401,
            {"WWW-Authenticate": "Basic realm='Login Required'"},
        )

    @wraps(f)
    def decorated(*args, **kwargs):
        # NOTE: This example will require Basic Auth only when you run the
        # app directly. For unit tests, we can't block it from getting the
        # Swagger specs so we just allow it to go thru without auth.
        # The following two lines of code wouldn't be needed in a normal
        # production environment.
        if __name__ != "__main__":
            return f(*args, **kwargs)

        auth = request.authorization
        if not auth or not check_auth(auth.username, auth.password):
            return authenticate()
        return f(*args, **kwargs)

    return decorated
996976
def _add_auth_headers(self, base):
        """"""
        if 'access_token' in self.creds:
            return _extend(base, {
                'authorization': 'Bearer ' + self.creds['access_token']
            })
        return base
811682
private void requestAuthorization(HttpServletResponse resp) throws IOException {

        // Authorisation is required for the requested action.
        resp.setHeader(CmsRequestUtil.HEADER_WWW_AUTHENTICATE, "Basic realm=\"" + BASIC_REALM + "\"");

        resp.sendError(HttpServletResponse.SC_UNAUTHORIZED);
    }
321871
def set_basic_auth(uri, user, passwd)
    uri = urify(uri)
    @www_auth.basic_auth.set(uri, user, passwd)
    reset_all
  end
181117
def basic_auth(self, response=None):
        """"""
        auth = request.authorization
        if auth and self._login_checker({'username': auth.username,
                                         'password': auth.password}):
            session['simple_logged_in'] = True
            session['simple_basic_auth'] = True
            session['simple_username'] = auth.username
            return response or True
        else:
            headers = {'WWW-Authenticate': 'Basic realm="Login Required"'}
            return 'Invalid credentials', 401, headers
48811
private function setAccessToken()
    {
        $url = $this->client->url . '/identity/oauth/token';
        $clientId = $this->client->clientId;
        $clientSecret = $this->client->clientSecret;
        $queryString = "?grant_type=client_credentials&client_id=$clientId&client_secret=$clientSecret";

        $response = json_decode(
            $this->client->guzzle
                ->request('GET', $url . $queryString)
                ->getBody()
                ->getContents()
        );

        $this->client->setAccessToken($response->access_token);
    }
1244198
def _auth(url, user, passwd, realm):
    '''
    
    '''

    basic = _HTTPBasicAuthHandler()
    basic.add_password(realm=realm, uri=url, user=user, passwd=passwd)
    digest = _HTTPDigestAuthHandler()
    digest.add_password(realm=realm, uri=url, user=user, passwd=passwd)
    return _build_opener(basic, digest)
213010
def authorize_from_request(rtoken, rsecret, verifier_or_pin)
      request_token = ::OAuth::RequestToken.new(consumer, rtoken, rsecret)
      access_token = request_token.get_access_token(:oauth_verifier => verifier_or_pin)
      @atoken, @asecret = access_token.token, access_token.secret
    end
455542
def authenticate(self, api_key):
        """"""
        self._api_key = api_key

        # Attach auth to session.
        self._session.auth = ('', self._api_key)

        return self._verify_api_key()
481789
def authorized(self, request_token):
        """"""
        verifier = generate_token(length=self.verifier_length[1])
        self.save_verifier(request_token, verifier)
        response = [
            (u'oauth_token', request_token),
            (u'oauth_verifier', verifier)
        ]
        callback = self.get_callback(request_token)
        return redirect(add_params_to_uri(callback, response))
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
388282
def auth(self):
        """"""
        response = requests.post(
            parse.urljoin(self.base_url, '/api/auth'),
            timeout=self.timeout,
            data={'username': self.username, 'password': self.password})
        response.raise_for_status()
        json = response.json()
        if 'jwt' not in json:
            raise ValueError("Not authorized: didn't receive token, check username or password.")
        self.jwt = json['jwt']
        return json
1110145
def add_auth(f):
    """"""

    def add_auth_decorator(*args, **kwargs):
        token = get_user_token()
        if 'headers' not in kwargs:
            kwargs['headers'] = {}
        kwargs['headers']['Authorization'] = "Bearer %s" % token
        return f(*args, **kwargs)

    return add_auth_decorator
1236023
public T basic(String user, String password){
        connection.setRequestProperty("Authorization", "Basic " + toBase64((user + ":" + password).getBytes()));
        return (T) this;
    }