Create Session to store credentials.

        Returns
            (Session)
                A Session object with OAuth 2.0 credentials.
493134
def get_session(self):
        
        response = _request_access_token(
            grant_type=auth.CLIENT_CREDENTIALS_GRANT,
            client_id=self.client_id,
            client_secret=self.client_secret,
            scopes=self.scopes,
        )

        oauth2credential = OAuth2Credential.make_from_response(
            response=response,
            grant_type=auth.CLIENT_CREDENTIALS_GRANT,
            client_id=self.client_id,
            client_secret=self.client_secret,
        )

        return Session(oauth2credential=oauth2credential)
213308
def session(self):
        
        return self.session_class(
            client_key=self.client_key,
            client_secret=self.client_secret,
            signature_method=self.signature_method,
            signature_type=self.signature_type,
            rsa_key=self.rsa_key,
            client_class=self.client_class,
            force_include_body=self.force_include_body,
            blueprint=self,
            base_url=self.base_url,
            **self.kwargs
        )
575876
def _session():
    '''
    
    '''

    config = __salt__['config.option']('zenoss')
    session = requests.session()
    session.auth = (config.get('username'), config.get('password'))
    session.verify = False
    session.headers.update({'Content-type': 'application/json; charset=utf-8'})
    return session
1142010
def from_credentials(credentials):
        
        return API(username=credentials.username, password=credentials.password,
                   database=credentials.database, session_id=credentials.session_id,
                   server=credentials.server)
814843
def _create_session(self):
        
        self.driver = requests.Session(**self.driver_args)
        # Set default headers
        self.update_headers(self.current_headers)
        self.update_cookies(self.current_cookies)
        self.set_proxy(self.current_proxy)
329043
def make_session(self):
        """"""
        with connect_lock:
            if self._sf_session is None:
                sf_session = requests.Session()
                # TODO configurable class Salesforce***Auth
                sf_session.auth = SalesforcePasswordAuth(db_alias=self.alias,
                                                         settings_dict=self.settings_dict)
                sf_instance_url = sf_session.auth.instance_url
                sf_requests_adapter = HTTPAdapter(max_retries=get_max_retries())
                sf_session.mount(sf_instance_url, sf_requests_adapter)
                # Additional headers work, but the same are added automatically by "requests' package.
                # sf_session.header = {'accept-encoding': 'gzip, deflate', 'connection': 'keep-alive'} # TODO
                self._sf_session = sf_session
857120
def create(self, session):
        
        sessionid = super().create(session)  # calls _do_create and verify
        self._cache(session, sessionid)
        return sessionid
266989
async def create_connection(self):
        ''''''
        connector = self.proxy or self.loop
        return await connector.create_connection(
            self.session_factory, self.host, self.port, **self.kwargs)
460813
def _create_session(team, auth):
    
    session = requests.Session()
    session.hooks.update(dict(
        response=partial(_handle_response, team)
    ))
    session.headers.update({
        "Content-Type": "application/json",
        "Accept": "application/json",
        "User-Agent": "quilt-cli/%s (%s %s) %s/%s" % (
            VERSION, platform.system(), platform.release(),
            platform.python_implementation(), platform.python_version()
        )
    })
    if auth is not None:
        session.headers["Authorization"] = "Bearer %s" % auth['access_token']

    return session
430500
def refresh_oauth_credential(self):
        """"""
        credential = self.session.oauth2credential

        if credential.is_stale():
            refresh_session = refresh_access_token(credential)
            self.session = refresh_session
103680
def create(self, instance):
        
        with self.flushing():
            if instance.id is None:
                instance.id = self.new_object_id()
            self.session.add(instance)
        return instance
1360099
def create_exposed_session(self, session, key=None, context=None):
        
        if key:
            return WebDelegatingSession(self, key)

        web_registry = context['web_registry']
        session_key = WebSessionKey(session.session_id,
                                    web_registry=web_registry)

        return WebDelegatingSession(self, session_key)
1188171
def _get_oauth_session(self):
        

        return self._get_session(
            OAuth2Session(
                client_id=self.client_id,
                token=self.token,
                token_updater=self.token_updater,
                auto_refresh_url=self.token_url,
                auto_refresh_kwargs={
                    "client_id": self.client_id,
                    "client_secret": self.client_secret
                }
            )
        )
450349
def create_token(credential, opts = {})
      data, _status_code, _headers = create_token_with_http_info(credential, opts)
      return data
    end
660774
def create_session(self):
        
        ret = requests.Session()
        ret.headers['User-Agent'] = self.user_agent
        for k, v in self.options.items():
            setattr(ret, k, v)
        return ret
703742
static OAuth2Credentials createOAuth2Credentials(SessionConfiguration config) throws IOException {


        return new OAuth2Credentials.Builder()
                .setCredentialDataStoreFactory(MemoryDataStoreFactory.getDefaultInstance())
                .setRedirectUri(config.getRedirectUri())
                .setScopes(config.getScopes())
                .setClientSecrets(config.getClientId(), config.getClientSecret())
                .build();
    }
1345586
def init_session(self):
        
        if self.session:
            self.session.close()
        self.session = make_session(self.username,
                                    self.password,
                                    self.bearer_token,
                                    self.extra_headers_dict)