Generate session token
432712
public function generateToken($cookieBased)
    {
        if (isset($this->token)) {
            return;
        }

        $this->token = base_convert(md5(uniqid(rand(), true)), 16, 36);

        if ($cookieBased) {
            setcookie($this->getCookieName(), $this->token, time() + $this->cookie_lifetime, '/', '.' . getenv('HTTP_HOST'));

            return;
        }

        setcookie($this->getCookieName(), $this->token, time() + $this->cookie_lifetime, '/');
    }
1103058
public function generateToken()
    {
        $token = Mage::helper('core')->getRandomString(16);
        $this->addCookie(self::COOKIE_TOKEN, $token);
        $this->addCookie(self::COOKIE_TOKEN_CHECKSUM, $this->getChecksum(array('token' => $token)));
        return $this;
    }
933163
def generate_token(self, username):
        
        serializer = self.get_signature()
        return serializer.dumps(
            {
                'username': username,
                'hashhash': self.get_hashhash(username)
            }
        ).decode('UTF-8')
609712
def get_session_key(limedict):
    """"""
    url = limedict['url']
    user = limedict['username']
    password = limedict['password']
    params = {'username': user, 'password': password}
    data = set_params('get_session_key', params)
    req = requests.post(url, data=data, headers=headers)
    return {'token': req.json()['result'], 'user': user, 'url': url}
205376
protected function generateAccessToken()
    {
        $tokenLen = 40;
        if (file_exists('/dev/urandom')) { // Get 100 bytes of random data
            $randomData = file_get_contents('/dev/urandom', false, null, 0, 100) . uniqid(mt_rand(), true);
        } else {
            $randomData = mt_rand() . mt_rand() . mt_rand() . mt_rand() . microtime(true) . uniqid(mt_rand(), true);
        }
        return substr(hash('sha512', $randomData), 0, $tokenLen);
    }
864183
public function generateToken()
    {
        $token   = md5(__CLASS__.uniqid());

        $sesCont = new SessionContainer(self::SESSION_KEY);
        $sesCont->$token = time();
        $sesCont->setExpirationSeconds(30, $token);

        return $token;
    }
928468
def refresh_session_token(self):
        
        response = client.put('/users/{}/refreshSessionToken'.format(self.id), None)
        content = response.json()
        self._update_data(content)
        self._handle_save_result(False)
1342001
def gen_token():
    """"""
    return ''.join(
        random.choice(
            string.ascii_uppercase + string.ascii_lowercase + string.digits)
        for _ in range(32))
3831
public function generateToken($token_length=30, $prefix='') {
        $token_length = $token_length - strlen($prefix);
        if ($token_length < 0) { throw new Exception("Prefix is too long", 1); }
        
        $token = "";
        while (($len = strlen($token)) < $token_length) {
            $remaining_len = $token_length - $len;
            $bytes = random_bytes($remaining_len);
            $token .= substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $remaining_len);
        }

        return $prefix.$token;
    }
1106935
def create_token():
    '''
        
    '''
    username = id_generator()
    password = id_generator()
    create_couchdb_admin(username, password)
    create_token_file(username, password)

    return 'Token {} created'.format(username)
76231
def get_session_token(self):
        '''  '''
        # HTTP POST query to session authenticate API
        try:
            response = requests.post(self.__session_url__ + 'sessionauth/v1/authenticate',
                                     cert=(self.__crt__, self.__key__), verify=True)
        except requests.exceptions.RequestException as err:
            self.logger.error(err)
            raise
        if response.status_code == 200:
            # load json response as list
            data = json.loads(response.text)
            self.logger.debug(data)
            # grab token from list
            session_token = data['token']
        else:
            raise Exception('BAD HTTP STATUS: %s' % str(response.status_code))
        # return the token
        self.logger.debug(session_token)
        return session_token
625027
def _create_session(self, username, password):
    
    session = requests.Session()
    session.verify = False  # Depending on SSL cert is verifiable
    try:
      response = session.get(self.host_url)
    except requests.exceptions.ConnectionError:
      return False
    # Get the CSRF token from the response
    soup = BeautifulSoup(response.text, 'html.parser')
    csrf_token = soup.find('input', dict(name='csrf_token'))['value']
    login_data = dict(username=username, password=password)
    session.headers.update({
        'x-csrftoken': csrf_token,
        'referer': self.host_url
    })
    _ = session.post('{0:s}/login/'.format(self.host_url), data=login_data)
    return session
1335328
def login_token(api, username, password):
    """"""
    sentence = api('/login')
    token = tuple(sentence)[0]['ret']
    encoded = encode_password(token, password)
    tuple(api('/login', **{'name': username, 'response': encoded}))
446036
def set_session_token(self, session_token):
        
        self.session_token = session_token
        self._login_time = datetime.datetime.now()
656341
def token(self, adata, load):
        '''
        
        '''
        try:
            token = self.loadauth.get_tok(load['token'])
        except Exception as exc:
            log.error('Exception occurred when generating auth token: %s', exc)
            yield {}
        if not token:
            log.warning('Authentication failure of type "token" occurred.')
            yield {}
        for sub_auth in adata:
            for sub_adata in adata:
                if token['eauth'] not in adata:
                    continue
            if not ((token['name'] in adata[token['eauth']]) |
                    ('*' in adata[token['eauth']])):
                continue
            yield {'sub_auth': sub_auth, 'token': token}
        yield {}
31208
public function generateToken()
    {
        if (isset($this->token)) return;

        $this->token = base_convert(md5(uniqid(rand(), true)), 16, 36);
        setcookie($this->getCookieName(), $this->token, time() + $this->cookie_lifetime, '/');
    }
464873
public function generateToken()
    {
        do {
            $token = sha1(microtime());
        } while ($this->newQuery()->where(['token' => $token])->count() > 0);

        return $token;
    }