Get or generate a token used to prevent double submits to an action.  The token is stored in the session,
and checked (and removed) when processing an action with the <code>preventDoubleSubmit</code> attribute
set to <code>true</code>.
164543
public static String getToken(HttpServletRequest request, String action)
    {
        FlowController flowController = PageFlowUtils.getCurrentPageFlow(request);

        if (flowController != null) {
            MappingAndController mac = getActionMapping(request, flowController, action);
            if (mac != null) return getToken(request, mac.mapping);
        }

        return null;
    }
466175
protected Token fetchNumber() {
        Token result = Token.create(Token.TokenType.INTEGER, input.current());
        result.addToContent(input.consume());
        while (input.current().isDigit() || input.current().is(decimalSeparator) || (input.current()
                                                                                          .is(groupingSeparator)
                                                                                     && input.next().isDigit())) {
            if (input.current().is(groupingSeparator)) {
                result.addToSource(input.consume());
            } else if (input.current().is(decimalSeparator)) {
                if (result.is(Token.TokenType.DECIMAL)) {
                    problemCollector.add(ParseError.error(input.current(), "Unexpected decimal separators"));
                } else {
                    Token decimalToken = Token.create(Token.TokenType.DECIMAL, result);
                    decimalToken.setContent(result.getContents() + effectiveDecimalSeparator);
                    decimalToken.setSource(result.getSource());
                    result = decimalToken;
                }
                result.addToSource(input.consume());
            } else {
                result.addToContent(input.consume());
            }
        }

        return result;
    }
532082
def _oauth_tokengetter(token=None):
    
    token = session.get("oauth")
    log.debug("Token Get: {0}".format(token))
    return token
1325854
def fetch_token(self, **kwargs):
        """"""
        return super(AsanaOAuth2Session, self).fetch_token(self.token_url, client_secret=self.client_secret, **kwargs)
708837
def create_action_token(self, action, expires_in):
        
        return utils.sign_url_safe(self.user.id,
                                   secret_key=get_jwt_secret(),
                                   salt=action,
                                   expires_in=expires_in)
451679
public void getToken(GetTokenHandler handler) {
        HMSAgentLog.i("getToken:handler=" + StrUtils.objDesc(handler));
        this.handler = handler;
        retryTimes = MAX_RETRY_TIMES;
        connect();
    }
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()
1208976
public function getToken()
    {
        if (isset($_SESSION[$this->session_name])) {
            return $_SESSION[$this->session_name];
        } else {
            $token = uniqid($this->randomString());
            $_SESSION[$this->session_name] = $token;
            return $token;
        }
    }
635659
public function generateToken()
	{
		$controller = new AjaxController();
		$controller->restrictAccess(Auth::isAdmin());
		
		$token = Functions::generateRandomToken();		
		$this->module->setSetting('MAJ_AT_FORCE_EXEC_TOKEN', $token);
		Log::addConfigurationLog($this->module->getTitle().' : New token generated.');
		
		$controller->pageHeader();
		echo $token;
	}
855508
public final String getToken() {
    if (placeRequest == null) {
      return null;
    }
    if (placeRequest.getParameterNames() == null || placeRequest.getParameterNames().size() == 0) {
      return placeRequest.getNameToken();
    }
    final StringBuilder token = new StringBuilder();
    token.append(placeRequest.getNameToken());
    for (final String param : placeRequest.getParameterNames()) {
      token.append(';');
      token.append(param);
      token.append('=');
      token.append(placeRequest.getParameter(param, StringUtils.EMPTY));
    }
    return token.toString();
  }
642162
protected Token fetchSpecialId() {
        Token result = Token.create(Token.TokenType.SPECIAL_ID, input.current());
        result.addToTrigger(input.consume());
        while (isIdentifierChar(input.current())) {
            result.addToContent(input.consume());
        }
        return handleKeywords(result);
    }
1022936
public RefToken get(int index) throws IndexOutOfBoundsException {
        if (index < 0 || index >= tokens.length) throw new IndexOutOfBoundsException("Illegal index: " + index);
        return tokens[index];
    }
770193
public function generateToken( $action = -1 ) {
		$action = $action === -1 ? session_id() : $action;
		$this->token = wp_create_nonce( $action );
		return $this->getToken();
	}
1248116
public Api getActionResult(String action, String params, TokenResult token,
      Object pFormData) throws Exception {
    return getActionResult(action, params, token, pFormData, format);
  }
316670
protected Token fetchString() {
        char separator = input.current().getValue();
        char escapeChar = stringDelimiters.get(input.current().getValue());
        Token result = Token.create(Token.TokenType.STRING, input.current());
        result.addToTrigger(input.consume());
        while (!input.current().isNewLine() && !input.current().is(separator) && !input.current().isEndOfInput()) {
            if (escapeChar != '\0' && input.current().is(escapeChar)) {
                result.addToSource(input.consume());
                if (!handleStringEscape(separator, escapeChar, result)) {
                    problemCollector.add(ParseError.error(input.next(),
                                                          String.format("Cannot use '%s' as escaped character",
                                                                        input.next().getStringValue())));
                }
            } else {
                result.addToContent(input.consume());
            }
        }
        if (input.current().is(separator)) {
            result.addToSource(input.consume());
        } else {
            problemCollector.add(ParseError.error(input.current(), "Premature end of string constant"));
        }
        return result;
    }
348453
def _get_token(self):
        """"""
        # HTTP request
        try:
            raw_res = yield from self._session.get(TOKEN_URL,
                                                   headers=self._headers,
                                                   timeout=self._timeout)
        except OSError:
            raise PyFidoError("Can not get token")
        # Research for json in answer
        content = yield from raw_res.text()
        reg_res = re.search(r"\({.*}\)", content)
        if reg_res is None:
            raise PyFidoError("Can not finf token json")
        # Load data as json
        return_data = json.loads(reg_res.group()[1:-1])
        # Get token and uuid
        token = return_data.get('result', {}).get('accessToken')
        uuid = return_data.get('result', {}).get('userData', {}).get('uuid')
        # Check values
        if token is None or uuid is None:
            raise PyFidoError("Can not get token or uuid")

        return token, uuid
960545
def get_session(self, token_path=None):
        
        # TODO: remove token_path in future versions
        if token_path is not None:
            warnings.warn('"token_path" param will be removed in future versions.'
                          ' Use a TokenBackend instead.', DeprecationWarning)

        # gets a fresh token from the store
        token = self.token_backend.get_token()

        if token:
            client_id, _ = self.auth
            session = OAuth2Session(client_id=client_id, token=token)
        else:
            raise RuntimeError(
                'No auth token found. Authentication Flow needed')

        session.proxies = self.proxy

        if self.request_retries:
            retry = Retry(total=self.request_retries, read=self.request_retries,
                          connect=self.request_retries,
                          backoff_factor=RETRIES_BACKOFF_FACTOR,
                          status_forcelist=RETRIES_STATUS_LIST)
            adapter = HTTPAdapter(max_retries=retry)
            session.mount('http://', adapter)
            session.mount('https://', adapter)

        return session