Constructs the OAuth2 session object.
774993
def oauth_session(request, state=None, token=None):
    
    if settings.DISCORD_REDIRECT_URI is not None:
        redirect_uri = settings.DISCORD_REDIRECT_URI
    else:
        redirect_uri = request.build_absolute_uri(
            reverse('discord_bind_callback'))
    scope = (['email', 'guilds.join'] if settings.DISCORD_EMAIL_SCOPE
             else ['identity', 'guilds.join'])
    return OAuth2Session(settings.DISCORD_CLIENT_ID,
                         redirect_uri=redirect_uri,
                         scope=scope,
                         token=token,
                         state=state)
1215490
private function create(): CookieAuthSession
    {
        $response = $this->request($this->endpoint . $this->path, [
            RequestOptions::JSON => [
                'username' => $this->username,
                'password' => $this->password,
            ],
        ]);

        $body = $response->getBody();
        $body->seek(0);
        $contents = $body->getContents();

        $contents = json_decode($contents, true);

        if (isset($contents['session']['name'], $contents['session']['value'])) {
            return new CookieAuthSession($contents['session']['name'], $contents['session']['value']);
        }

        throw new \Exception('Failed to create ' . CookieAuthSession::class . '.');
    }
1202583
def create_session!
      # Skip authorizing if there was an error from the authorization.
      handle_token_error
      # Try to get a code (the rescue block will also prevent crazy crashes)
      access = @strategy.authenticate(@request.GET['code'])
      @request.session[:redd_session] = access.to_h
    rescue Errors::TokenRetrievalError, Errors::ResponseError => error
      @request.env['redd.error'] = error
    end
163838
def create_session(self, server_host, server_port, honeypot_id):
        
        protocol = self.__class__.__name__.lower()
        session = BaitSession(protocol, server_host, server_port, honeypot_id)
        self.sessions[session.id] = session
        return session
145244
def create_session(self, uid, duration=0):

        '''
            
        '''
    
        title = '%s.create_session' % self.__class__.__name__
        
    # validate inputs
        input_fields = {
            'uid': uid,
            'duration': duration
        }
        for key, value in input_fields.items():
            if value:
                object_title = '%s(%s=%s)' % (title, key, str(value))
                self.fields.validate(value, '.%s' % key, object_title)
        
    # construct request fields
        url = self.bucket_url + '/_session'
        json_data = {
            'name': uid
        }
        if duration:
            json_data['ttl'] = duration
    
    # send request and unwrap response
        response = requests.post(url, json=json_data)
        response = response.json()
    
        return response
939359
def _make_session():
        

        sess = requests.Session()
        sess.mount('http://', requests.adapters.HTTPAdapter(max_retries=False))
        sess.mount('https://', requests.adapters.HTTPAdapter(max_retries=False))

        return sess
1237746
public function init()
    {
        $serviceFactory = new \OAuth\ServiceFactory();
        $serviceFactory->setHttpClient(new CurlClient());
        $this->service = $serviceFactory->createService(
            $this->getServiceName(), $this->credentials, $this->sessionStorage, $this->scopes
        );

        return $this;
    }
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();
    }
1284550
function generateSession() {
    const session = {}
    //you can alter the cookie options in nexts
    session.cookie = {}
    for (const prop in cookie) {
      session.cookie[prop] = cookie[prop]
    }
    compatMaxage(session.cookie)
    return session
  }
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
628073
private HttpSession2 buildSession(String id, boolean refresh) {
        HttpSession2 session = new HttpSession2(id, sessionManager, request.getServletContext());
        session.setMaxInactiveInterval(maxInactiveInterval);
        if (refresh) {
            WebUtil.addCookie(this, response, getSessionCookieName(), id,
                    getCookieDomain(), getCookieContextPath(), cookieMaxAge, true);
        }
        return session;
    }
530563
def _create_websession(self):
        """"""
        from socket import AF_INET
        from aiohttp import ClientTimeout, TCPConnector

        _LOGGER.debug('Creating web session')
        conn = TCPConnector(
            family=AF_INET,
            limit_per_host=5,
            enable_cleanup_closed=True,
        )

        # Create session object.
        session_timeout = ClientTimeout(connect=10)
        self._websession = ClientSession(connector=conn,
                                         timeout=session_timeout)
        self._supplied_websession = False
447088
private function initSession()
    {
        $transport = $this->transportRegistry->getTransport($this->profile->get('transport', 'name'));
        $repository = $transport->getRepository($this->profile->get('transport'));

        $credentials = new SimpleCredentials(
            $this->profile->get('phpcr', 'username'),
            $this->profile->get('phpcr', 'password')
        );

        $session = $repository->login($credentials, $this->profile->get('phpcr', 'workspace'));

        // if you are wondering wtf here -- we wrap the PhpcrSession
        if (!$this->session) {
            $this->session = new PhpcrSession($session);
        } else {
            $this->session->setPhpcrSession($session);
        }
    }
332732
function generateSession() {
    const session = {};
    // you can alter the cookie options in nexts
    session.cookie = {};
    Object.keys(cookie).forEach((prop) => {
      session.cookie[prop] = cookie[prop];
    });
    return session;
  }
1337193
private function constructIdentityToken() {
		if (isset($_REQUEST[self::CODE])) {
			$this->requestToken($_REQUEST[self::CODE], self::IDENTITY_TOKEN);
			$_SESSION[self::SESSION][self::IS_API_TOKEN] = false;
			$_SESSION[self::SESSION][self::STATE] = self::NEGOTIATION_COMPLETE;
			header("Location: {$_SESSION[self::SESSION][self::LANDING_PAGE]}");
			exit;
		} elseif (isset($_REQUEST[self::ERROR])) {
			$_SESSION[self::SESSION][self::STATE] = self::NEGOTIATION_FAILED;
			$_SESSION[self::SESSION][self::ERROR] = $_REQUEST[self::ERROR];
			header("Location: {$_SESSION[self::SESSION][self::LANDING_PAGE]}?error={$_REQUEST[self::ERROR]}");
			exit;
		} else {
			throw new OAuthNegotiator_Exception(
				'Unexpected OAuth response',
				OAuthNegotiator_Exception::CODE_RESPONSE
			);
		}
	}
1288987
protected function session()
    {
        if (tao_helpers_Context::check('APP_MODE')) {
            // Set a specific ID to the session.
            $request = new \Request();
            if ($request->hasParameter('session_id')) {
                session_id($request->getParameter('session_id'));
            }
        }

        // set the session cookie to HTTP only.

        $this->configureSessionHandler();

        $sessionParams = session_get_cookie_params();
        $cookieDomain = ((true == tao_helpers_Uri::isValidAsCookieDomain(ROOT_URL)) ? tao_helpers_Uri::getDomain(ROOT_URL) : $sessionParams['domain']);
        $isSecureFlag = \common_http_Request::isHttps();
        session_set_cookie_params($sessionParams['lifetime'], tao_helpers_Uri::getPath(ROOT_URL), $cookieDomain, $isSecureFlag, TRUE);
        session_name(GENERIS_SESSION_NAME);

        if (isset($_COOKIE[GENERIS_SESSION_NAME])) {

            // Resume the session
            session_start();

            //cookie keep alive, if lifetime is not 0
            if ($sessionParams['lifetime'] !== 0) {
                $expiryTime = $sessionParams['lifetime'] + time();
                setcookie(session_name(), session_id(), $expiryTime, tao_helpers_Uri::getPath(ROOT_URL), $cookieDomain, $isSecureFlag, true);
            }
        }
    }
62595
protected function createClient()
    {
        $this->client = new OAuthServer([
            'identifier' => Configuration::get('key'),
            'secret' => Configuration::get('secret'),
            'callback_uri' => Configuration::get('callbackUrl'),
            'name' => Configuration::get('name'),
            'expiration' => Configuration::get('expiration'),
            'scope' => Configuration::get('scope'),
        ]);

        return $this;
    }