:rtype: str
        :returns: a CSRF token
333970
def new_csrf_token(self, session_key):
        
        try:
            csrf_token = self._generate_csrf_token()

            session = self._lookup_required_session(session_key)
            session.set_internal_attribute('csrf_token', csrf_token)
            self.session_handler.on_change(session)

        except AttributeError:
            raise CSRFTokenException('Could not save CSRF_TOKEN to session.')

        return csrf_token
684115
def check_csrf_token():
    """"""
    if request.method in ("GET",): # not exhaustive list
        return
    token = request.form.get("csrf_token")
    if token is None:
        app.logger.warning("Expected CSRF Token: not present")
        abort(400)
    if not safe_str_cmp(token, csrf_token()):
        app.logger.warning("CSRF Token incorrect")
        abort(400)
335949
async def createcsrf(self, csrfarg = '_csrf'):
        
        await self.sessionstart()
        if not csrfarg in self.session.vars:
            self.session.vars[csrfarg] = uuid.uuid4().hex
1018030
def client_tokens(self):
        
        client_id, client_secret = self.get_auth_basic()
        if not client_id and not client_secret:
            client_id = self.query_kwargs.get('client_id', '')
            client_secret = self.query_kwargs.get('client_secret', '')
            if not client_id and not client_secret:
                client_id = self.body_kwargs.get('client_id', '')
                client_secret = self.body_kwargs.get('client_secret', '')

        return client_id, client_secret
869381
def get_token(self):
        
        self.bbox_auth.set_access(BboxConstant.AUTHENTICATION_LEVEL_PRIVATE, BboxConstant.AUTHENTICATION_LEVEL_PRIVATE)
        self.bbox_url.set_api_name(BboxConstant.API_DEVICE, "token")
        api = BboxApiCall(self.bbox_url, BboxConstant.HTTP_METHOD_GET, None,
                          self.bbox_auth)
        resp = api.execute_api_request()
        return resp.json()[0]['device']['token']
195664
def _get_web_auth_token(self):
        

        request = _Request(self.network, "auth.getToken")

        # default action is that a request is signed only when
        # a session key is provided.
        request.sign_it()

        doc = request.execute()

        e = doc.getElementsByTagName("token")[0]
        return e.firstChild.data
699155
def token(self):
        
        if self._token is None or \
           datetime.datetime.now() >= self._token_expires_on:
            self._generateForOAuthSecurity(self._client_id,
                                           self._secret_id,
                                           self._token_url)
        return self._token
357901
def validate_csrf_token(self, field):
        """"""
        if current_app.testing:
            return
        super(InvenioBaseForm, self).validate_csrf_token(field)
657643
def _get_token(self):
        '''
        
        '''
        self.session.token = self.request(
            'getCommunicationToken',
            {'secretKey': self.session.secret},
            {'uuid': self.session.user,
             'session': self.session.session,
             'clientRevision': grooveshark.const.CLIENTS['htmlshark']['version'],
             'country': self.session.country,
             'privacy': 0,
             'client': 'htmlshark'})[1]
        self.session.time = time.time()
10379
def get_request_token(self):
        
        
        if self._request_token is None:
            self._request_token = self._get_request_token()
        return self._request_token
540019
def token(self):
        
        if not self._token:
            self._token = self.fetch_token()
            logger.payment(self)
        return self._token
981138
public static function getCsrfToken(): string
    {
        if (!self::has('CSRF_TOKEN')) {
            self::put('CSRF_TOKEN', Str::random(32));
        }

        return self::get('CSRF_TOKEN');
    }
1232719
def _get_token(request):
    
    token = request.headers.get('Authorization')
    if not token:
        message = 'Token not in Authorization header'
        logging.warning(message)
        raise HTTPError(401, message)
    return token
1193827
public static function getStoredToken(): Token
    {
        if (static::$token !== null) {
            return static::$token;
        }

        $sessionKeyName = static::getSessionKeyName();

        if ($sessionKeyName === null || strlen($sessionKeyName) == 0) {
            throw new Exception('Can not get stored CSRF token when session key is not set');
        }

        $token = Session::get($sessionKeyName);

        if ($token === null) {
            throw new SecurityException('There is no stored token on backend');
        }

        static::$token = $token;
        return $token;
    }
1038663
def to_dict(self):
        
        data = dict()
        data['api_url'] = self.api_url
        data['api_key'] = self.api_key
        data['verifySSL'] = self.verifySSL
        data['client_id'] = self.client_id
        data['client_secret'] = self.client_secret
        data['redirect_url'] = self.redirect_url
        data['token'] = self.token
        data['state'] = self.state
        data['auth_url'] = self.auth_url
        return data
275519
def token(self):
        
        if self._token is None:
            token_type = os.getenv(TOKEN_TYPE_KEY, '')
            token_body = os.getenv(TOKEN_BODY_KEY, '')
            self._token = _Token(token_type, token_body)
        return self._token
576984
def protect(view):
    

    @wraps(view)
    def csrf_check(*args, **kwargs):
        # an empty form is used to validate current csrf token and only that!
        if not FlaskForm().validate():
            raise Forbidden("CSRF validation failed.")

        return view(*args, **kwargs)

    return csrf_check