Move client credentials to the config.
Signed-off-by: Jan Losinski <losinski@wh2.tu-dresden.de>
This commit is contained in:
parent
d97c6f6a85
commit
0f56408bc7
|
|
@ -1,9 +1,11 @@
|
|||
class Config:
|
||||
|
||||
def __init__(self, wallabag_host, db_uri, tag='kindle', refresh_grace=120, consume_interval=30,
|
||||
interface_host="127.0.0.1", interface_port=8080):
|
||||
def __init__(self, wallabag_host, db_uri, client_id, client_secret, tag='kindle', refresh_grace=120,
|
||||
consume_interval=30, interface_host="127.0.0.1", interface_port=8080):
|
||||
self.wallabag_host = wallabag_host
|
||||
self.db_uri = db_uri
|
||||
self.client_id = client_id
|
||||
self.client_secret = client_secret
|
||||
self.tag = tag
|
||||
self.refresh_grace = refresh_grace
|
||||
self.consume_interval = consume_interval
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from sqlalchemy import create_engine
|
||||
from sqlalchemy import Integer, String, DateTime, Column, ForeignKey, Enum
|
||||
from sqlalchemy.orm import scoped_session, sessionmaker, relationship
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.orm import sessionmaker, relationship
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
|
|
@ -11,8 +11,6 @@ class User(Base):
|
|||
|
||||
name = Column(String, primary_key=True)
|
||||
token = Column(String())
|
||||
client_id = Column(String())
|
||||
client_secret = Column(String())
|
||||
auth_token = Column(String)
|
||||
refresh_token = Column(String)
|
||||
token_valid = Column(DateTime)
|
||||
|
|
|
|||
|
|
@ -32,15 +32,15 @@ def make_tags(tag):
|
|||
|
||||
|
||||
class Wallabag:
|
||||
def __init__(self, host_url):
|
||||
self.url = host_url
|
||||
def __init__(self, config):
|
||||
self.config = config
|
||||
self.tag = "kindle"
|
||||
self.tags = make_tags(self.tag)
|
||||
|
||||
async def get_token(self, user, passwd):
|
||||
params = {'grant_type': 'password',
|
||||
'client_id': user.client_id,
|
||||
'client_secret': user.client_secret,
|
||||
'client_id': self.config.client_id,
|
||||
'client_secret': self.config.client_secret,
|
||||
'username': user.name,
|
||||
'password': passwd}
|
||||
|
||||
|
|
@ -60,8 +60,8 @@ class Wallabag:
|
|||
async def refresh_token(self, user):
|
||||
params = {'grant_type': 'refresh_token',
|
||||
'client_id': user.client_id,
|
||||
'client_secret': user.client_secret,
|
||||
'refresh_token': user.refresh_token,
|
||||
'client_secret': self.config.client_secret,
|
||||
'refresh_token': self.config.refresh_token,
|
||||
'username': user.name}
|
||||
|
||||
async with aiohttp.ClientSession() as session:
|
||||
|
|
@ -84,7 +84,7 @@ class Wallabag:
|
|||
return params
|
||||
|
||||
def _url(self, url):
|
||||
return self.url + url
|
||||
return self.config.wallabag_host + url
|
||||
|
||||
async def fetch_entries(self, user):
|
||||
if user.auth_token is None:
|
||||
|
|
|
|||
Loading…
Reference in New Issue