token management
436542
public ServerAccessToken createAccessToken(AccessTokenRegistration reg)
		throws OAuthServiceException {
		ServerAccessToken token = new BearerAccessToken(reg.getClient(), 3600L);
		
		List<String> scope = reg.getApprovedScope().isEmpty() ? reg.getRequestedScope() 
				                                              : reg.getApprovedScope();
		token.setScopes(convertScopeToPermissions(reg.getClient(), scope));
		token.setSubject(reg.getSubject());
		token.setGrantType(reg.getGrantType());
		
		at = token;
		
		return token;
	}
162324
private function encryptAllRefreshTokens()
    {
        $userCollection = $this->userCollectionFactory->create()
            ->addFieldToFilter('refresh_token', ['notnull' => true]);

        foreach ($userCollection as $user) {
            $this->encryptAndSaveRefreshToken($user);
        }
    }
498194
protected function processToken(): void
    {
        $this->file->recordMetric($this->getStackPos(), 'Used comparison (for array checks)', $this->token['type']);

        $nextTokenPos = TokenHelper::findNextEffective($this->getFile(), $startPos = $this->getStackPos() + 1);
        $nextToken = $this->tokens[$nextTokenPos];

        // Add in Array check
        if (array_key_exists($nextToken['code'], $this->invalidStructure)) {
            $this->checkArrayStructure($this->invalidStructure[$nextToken['code']], $nextTokenPos + 1);
        } else {
            $this->file->recordMetric(
                $startPos,
                'Invalid array comparison',
                'no'
            );
        }
    }
923304
def update_by_token(self, token, **kwargs):
        
        _sid = self.handler.sid(token)
        return self.update(_sid, **kwargs)
1040151
private function tokens(): void
    {
        foreach ($this->attributes as $attribute => $value) {
            switch ($attribute) {
                case Options::ATTRIBUTE_BOLD:
                    $this->tokens[] = Options::MARKDOWN_TOKEN_BOLD;
                    break;

                case Options::ATTRIBUTE_ITALIC:
                    $this->tokens[] = Options::MARKDOWN_TOKEN_ITALIC;
                    break;

                default:
                    break;
            }
        }
    }
796312
def generate_token(self):
        """"""

        response = self._make_request()
        self.auth = response
        self.token = response['token']
453691
protected function processToken(): void
    {
        try {
            $this->checkAndRegisterMissingDocBlock();
            $this->checkAndRegisterNoMultiLine();
        } catch (CodeWarning $error) {
            $this->getExceptionHandler()->handleException($error);
        }
    }
142729
def _BuildToken(self, request, execution_time):
    """"""
    token = access_control.ACLToken(
        username=request.user,
        reason=request.args.get("reason", ""),
        process="GRRAdminUI",
        expiry=rdfvalue.RDFDatetime.Now() + execution_time)

    for field in ["Remote_Addr", "X-Forwarded-For"]:
      remote_addr = request.headers.get(field, "")
      if remote_addr:
        token.source_ips.append(remote_addr)
    return token
670192
def __add_tokenization(self, tree):
        """"""
        for token_id in self.get_token_ids(tree):
            self.add_node(token_id, layers={self.ns})
            self.tokens.append(token_id)
48449
private function saveToken()
	{
		$fd = fopen($this->cacheFolder."/token.txt", 'w');
		fwrite($fd, $this->token);
		fclose($fd);
	}
405759
def add_token_object(self, token):
        '''  '''
        token.sent = self  # take ownership of given token
        self.__tokens.append(token)
        return token
194115
function tokenDealer(tokens, fn, options) {
    if (!tokens || !tokens.length) {
        tokens = [''];
    }

    options = {
        group: 'default',
        wait: false,
        lru: defaultLru,
        onExhausted: null,
        ...options,
    };

    return dealToken(tokens, fn, options);
}
751222
def handle_sd_rmn_sy(tokens, options)
      new_tokens = [tokens[1], tokens[0], tokens[2]]
      time_tokens = tokens.last(tokens.size - 3)
      handle_rmn_sd_sy(new_tokens + time_tokens, options)
    end
832482
function createToken (client) {
  return ask([
    {"type": "input",     "message": "Username", "name": "user"},
    {"type": "password",  "message": "Password", "name": "password"}
  ]).then(function (answers) {
    return client.createToken(answers.username, answers.password)
      .then(saveToken)
      .then(function (token) {
        // Authorize client…
        client.setToken(token);
        // …and send it back to connect()
        return client;
      });
  });
}
526990
def process_token(type, token)
      # Remove the "Bot " prefix if it exists
      token = token[4..-1] if token.start_with? 'Bot '

      token = 'Bot ' + token unless type == :user
      token
    end
29517
public static synchronized void updateTokens(Collection<Token> tokens)
    {
        assert !tokens.isEmpty() : "removeEndpoint should be used instead";
        String req = "INSERT INTO system.%s (key, tokens) VALUES ('%s', ?)";
        executeInternal(String.format(req, LOCAL_CF, LOCAL_KEY), tokensAsSet(tokens));
        forceBlockingFlush(LOCAL_CF);
    }
1046502
def mk_token(self, load):
        '''
        
        '''
        if not self.authenticate_eauth(load):
            return {}

        if self._allow_custom_expire(load):
            token_expire = load.pop('token_expire', self.opts['token_expire'])
        else:
            _ = load.pop('token_expire', None)
            token_expire = self.opts['token_expire']

        tdata = {'start': time.time(),
                 'expire': time.time() + token_expire,
                 'name': self.load_name(load),
                 'eauth': load['eauth']}

        if self.opts['keep_acl_in_token']:
            acl_ret = self.__get_acl(load)
            tdata['auth_list'] = acl_ret

        groups = self.get_groups(load)
        if groups:
            tdata['groups'] = groups

        return self.tokens["{0}.mk_token".format(self.opts['eauth_tokens'])](self.opts, tdata)