request token is a dict, not a string

This commit is contained in:
b3yond 2018-04-14 17:19:20 +02:00
parent 45d4cd2062
commit bf7c21c113
2 changed files with 7 additions and 5 deletions

1
db.py
View file

@ -79,6 +79,7 @@ class DB(object):
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
user_id INTEGER,
request_token TEXT,
request_token_secret TEXT,
FOREIGN KEY(user_id) REFERENCES user(id)
);
CREATE TABLE IF NOT EXISTS twitter_accounts (

11
user.py
View file

@ -128,16 +128,17 @@ class User(object):
return dict(foo='bar')
def save_request_token(self, token):
db.execute("INSERT INTO twitter_request_tokens(user_id, request_token) VALUES(?, ?);",
(self.uid, token))
db.execute("INSERT INTO twitter_request_tokens(user_id, request_token, request_token_secret) VALUES(?, ?, ?);",
(self.uid, token["oauth_token"], token["oauth_token_secret"]))
db.commit()
def get_request_token(self):
db.execute("SELECT request_token FROM twitter_request_tokens WHERE user_id = ?;", (id,))
request_token = db.cur.fetchone()[0]
db.execute("SELECT request_token, request_token_secret FROM twitter_request_tokens WHERE user_id = ?;", (id,))
request_token = db.cur.fetchone()
db.execute("DELETE FROM twitter_request_tokens WHERE user_id = ?;", (id,))
db.commit()
return request_token
return {"oauth_token" : request_token[0],
"oauth_token_secret" : request_token[1]}
def save_twitter_token(self, access_token, access_token_secret):
db.execute(