Save the token to the database
973921
public function saveToken($token, $configId = false)
    {
        $this->token = $token;
        $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig')->saveToken($token, $configId);
    }
567264
public function save ()
    {
        $Statement = $this->dbTable->getSql()->prepareStatementForSqlObject($this->sqlInsert);
        $Statement->execute();
        $this->id = $this->dbTable->getAdapter()->getDriver()->getConnection()->getLastGeneratedValue();
    }
764816
public function setTokens()
    {
        if (! isset($this->DMT_columns)) {
            throw new Exception("No Columns settings found in model, please see our package documentation https://github.com/F54it/laravel-token");
        }

        $table = $this->getTable();
        $token = new Token();
        foreach ($this->DMT_columns as $column => $settings) {
            $generated_token = null;
            switch ($settings['type']) {
                case Token::UNIQUE_NUMBER:
                    $generated_token = $token->uniqueNumber($table, $column, $settings['size'], $settings['special_chr']);

                    break;
                case Token::UNIQUE_STRING:
                    $generated_token = $token->uniqueString($table, $column, $settings['size'], $settings['special_chr']);

                    break;
                case Token::RANDOM:
                    $generated_token = $token->random($settings['size'], $settings['special_chr']);

                    break;
                case Token::RANDOM_NUMBER:
                    $generated_token = $token->randomNumber($settings['size'], $settings['special_chr']);

                    break;
                case Token::RANDOM_STRING:
                    $generated_token = $token->randomString($settings['size'], $settings['special_chr']);

                    break;
                case Token::UNIQUE:
                default:
                    $generated_token = $token->unique($table, $column, $settings['size'], $settings['special_chr']);
                    break;
            }
            $this->attributes[$column] = $generated_token;
        }
    }
1034792
public function createToken()
    {
        $hashProvider = HashProvider::getProvider();
        $token = $hashProvider->createHash($this->getSavedPasswordTokenData(), sha1($this->Password));

        $this->Token = $token;
        $this->TokenExpiry = date("Y-m-d H:i:s", strtotime("+2 weeks"));
        $this->save();

        return $token;
    }
42182
@Override
    public void store(OAuthToken token, String envKey) {
        oAuthToken.put(envKey, token);
    }
596
def post(self):
        """"""
        self.set_header("Content-Type", "application/json")
        key = uuid.uuid4().hex
        metadata = json.loads(self.request.body.decode())
        metadata["uuid"] = key
        self.database[key] = metadata
        result = json.dumps({"uuid": key})
        self.write(result)
329200
protected function generateToken()
    {
        if ($this->token === null) {
            $secret = array(
                'install' => __DIR__,
                'name' => $this->name,
            );

            if (isset($_SESSION)) {
                $key = sha1(__DIR__ . '/' . 'formidable_secret');

                if (isset($_SESSION[$key])) {
                    $secret['csrf'] = $_SESSION[$key];
                } else {
                    $csrf = sha1(uniqid(mt_rand(), true).'|'.gettimeofday(true));
                    $_SESSION[$key] = $csrf;
                    $secret['csrf'] = $csrf;
                }
            }

            $this->token = sha1(serialize($secret));
        }
    }
267084
public function addToken(Token $token)
    {
        $this->load();
        parent::addToken($token);
        $this->save();
    }
940134
def save_token(self, access_token):
        
        self.write(access_token.token, access_token.__dict__)

        unique_token_key = self._unique_token_key(access_token.client_id,
                                                  access_token.grant_type,
                                                  access_token.user_id)
        self.write(unique_token_key, access_token.__dict__)

        if access_token.refresh_token is not None:
            self.write(access_token.refresh_token, access_token.__dict__)
213069
def _store_token(self, token, remember=False):
        """"""
        if token and remember:
            try:
                keyring.set_password('github', 'token', token)
            except Exception:
                if self._show_msgbox:
                    QMessageBox.warning(self.parent_widget,
                                        _('Failed to store token'),
                                        _('It was not possible to securely '
                                          'save your token. You will be '
                                          'prompted for your Github token '
                                          'next time you want to report '
                                          'an issue.'))
                remember = False
        CONF.set('main', 'report_error/remember_token', remember)
327789
public function add()
    {
        $this->Crud->on('afterSave', function (Event $event) {
            if ($event->subject->created) {
                $token = [
                    'id' => $event->subject->entity->id,
                    'exp' => time() + 60 * 60 * 24 * 7,
                ];
                $this->set('data', [
                    'id' => $event->subject->entity->id,
                    'token' => JWT::encode($token, Security::salt())
                ]);
                $this->Crud->action()->config('serialize.data', 'data');
            }
            $signupEvent = new Event('Users.afterSignup', $event->subject());
            $this->eventManager()->dispatch($signupEvent);
        });
        return $this->Crud->execute();
    }
1010210
public function save()
    {
        $this->_dsql()->owner->beginTransaction();
        $this->hook('beforeSave');

        // decide, insert or modify
        if ($this->loaded()) {
            $res = $this->modify();
        } else {
            $res = $this->insert();
        }

        $res->hook('afterSave');
        $this->_dsql()->owner->commit();

        return $res;
    }
1184054
async def save(self):
        

        if hasattr(self, "before_save"):
            self.before_save()

        query = r.table(self.table_name)

        if self._state.get("id"):
            query = query \
                .get(self._state.get("id")) \
                .update(self.__db_repr, return_changes=True)
        else:
            query = query \
                .insert(self.__db_repr, return_changes=True)

        resp = await query.run(await conn.get())

        try:
            changes = resp["changes"]

            if len(changes) > 0:
                self.wrap(resp["changes"][0]["new_val"])
        except KeyError:
            raise UnexpectedDbResponse()

        if resp["skipped"] > 0:
            raise UnexpectedDbResponse(
                "Model with id `%s` not found in the database." %
                self._state.get("id"))

        return self
772509
def update_token(self, token, secret):
        
        if self.access_token != token or self.secret != secret:
            with db.session.begin_nested():
                self.access_token = token
                self.secret = secret
                db.session.add(self)
1101961
protected function updateTokenExpiry()
    {
        \DB::table($this->tokenTable)->where('token', $this->getToken())->update([
            $this->getTokenColumn('expire') => Carbon::parse('now '. $this->getTokenLifetime()),
        ]);
    }
706729
def save(self):
        
        if self.parent.buffered:
            query = """
                INSERT DATA { GRAPH %s { %s } }
            """
            query = query % (self.identifier.n3(),
                             self.graph.serialize(format='nt'))
            self.parent.graph.update(query)
            self.flush()
        else:
            self.meta.generate()
1018099
public function saveToken($token)
    {
        $rows = $this->_db->query(
            'UPDATE '.$this->_dbConfig['table']
                        .' SET '.$this->_dbConfig['token'].' = :tk'
                        .' WHERE '.$this->_dbConfig['id'].' = :id',
            [':tk'=>$token, ':id'=>$this->_data['id']]
        );
        if ($rows > 0) {
            $this->_data['token'] = $token;
            return true;
        }
        return false;
    }