-
Notifications
You must be signed in to change notification settings - Fork 1
/
service.py
27 lines (21 loc) · 898 Bytes
/
service.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from rauth.service import OAuth1Service
from config import CONSUMER_KEY, CONSUMER_SECRET
from postgres import conn
class MyOAuth1Service(OAuth1Service):
def get_db_tokens_session(self, user_id):
with conn.cursor() as cur:
cur.execute("SELECT access_token, access_token_secret "
"FROM tokens "
"where id = %s", (user_id,))
tokens = cur.fetchone()
if tokens and all(tokens):
return super().get_session(token=tokens)
goodreads_service = MyOAuth1Service(
consumer_key=CONSUMER_KEY,
consumer_secret=CONSUMER_SECRET,
name='goodreads',
request_token_url='https://www.goodreads.com/oauth/request_token',
authorize_url='https://www.goodreads.com/oauth/authorize',
access_token_url='https://www.goodreads.com/oauth/access_token',
base_url='https://www.goodreads.com/'
)