summaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/oauth.py
diff options
context:
space:
mode:
Diffstat (limited to 'gallery_dl/extractor/oauth.py')
-rw-r--r--gallery_dl/extractor/oauth.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/gallery_dl/extractor/oauth.py b/gallery_dl/extractor/oauth.py
index 74835bf..2f5b429 100644
--- a/gallery_dl/extractor/oauth.py
+++ b/gallery_dl/extractor/oauth.py
@@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-
-# Copyright 2017-2019 Mike Fährmann
+# Copyright 2017-2020 Mike Fährmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
-"""Utility classes to setup OAuth and link a users account to gallery-dl"""
+"""Utility classes to setup OAuth and link accounts to gallery-dl"""
from .common import Extractor, Message
from . import deviantart, flickr, reddit, smugmug, tumblr
@@ -38,7 +38,7 @@ class OAuthBase(Extractor):
print("Waiting for response. (Cancel with Ctrl+c)")
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
- server.bind(("localhost", 6414))
+ server.bind(("localhost", self.config("port", 6414)))
server.listen(1)
# workaround for ctrl+c not working during server.accept on Windows
@@ -98,7 +98,7 @@ class OAuthBase(Extractor):
def _oauth2_authorization_code_grant(
self, client_id, client_secret, auth_url, token_url,
scope="read", key="refresh_token", auth=True,
- message_template=None):
+ message_template=None, cache=None):
"""Perform an OAuth2 authorization code grant"""
state = "gallery-dl_{}_{}".format(
@@ -162,6 +162,11 @@ class OAuthBase(Extractor):
client_secret=client_secret,
))
+ # write to cache
+ if cache and config.get(("extractor", self.category), "cache"):
+ cache.update("#" + str(client_id), data[key])
+ self.log.info("Writing 'refresh-token' to cache")
+
class OAuthDeviantart(OAuthBase):
subcategory = "deviantart"
@@ -179,6 +184,7 @@ class OAuthDeviantart(OAuthBase):
"https://www.deviantart.com/oauth2/authorize",
"https://www.deviantart.com/oauth2/token",
scope="browse",
+ cache=deviantart._refresh_token_cache,
)