Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVilem Duha <vilem.duha@gmail.com>2019-05-29 16:01:01 +0300
committerVilem Duha <vilem.duha@gmail.com>2019-06-01 19:49:18 +0300
commit85fd48c32cbdb42f81b26bfb81d411d83e0898b0 (patch)
treebef0f8366dbe1aca4953cad20e87051468c36651 /blenderkit/oauth.py
parent88d0e75f1f35af1ea208565a6eb187162ed8451b (diff)
BlenderKit: convert all imports to importlib
+ new Oauth script version (finished in next commit) +split login/signup buttons
Diffstat (limited to 'blenderkit/oauth.py')
-rw-r--r--blenderkit/oauth.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/blenderkit/oauth.py b/blenderkit/oauth.py
index 61d6a7e8..e2846dab 100644
--- a/blenderkit/oauth.py
+++ b/blenderkit/oauth.py
@@ -26,10 +26,11 @@ import requests
class SimpleOAuthAuthenticator(object):
- def __init__(self, server_url, client_id, ports):
+ def __init__(self, server_url, client_id, ports, redirect_url):
self.server_url = server_url
self.client_id = client_id
self.ports = ports
+ self.redirect_url = redirect_url
def _get_tokens(self, authorization_code=None, refresh_token=None, grant_type="authorization_code"):
data = {
@@ -62,7 +63,14 @@ class SimpleOAuthAuthenticator(object):
if 'code' in self.path:
self.auth_code = self.path.split('=')[1]
# Display to the user that they no longer need the browser window
- self.wfile.write(bytes('<html><h1>You may now close this window.</h1></html>', 'utf-8'))
+ self.wfile.write(bytes(
+ '<html>'
+ '<head><meta http-equiv="refresh" content="0;url=%(redirect_url)s"></head>'
+ '<script> window.location.href="%(redirect_url)s"; </script>'
+ '<h1>You may now close this window.</h1>'
+ '</html>' % {'redirect_url': self.redirect_url},
+ 'utf-8',
+ ))
qs = parse_qs(urlparse(self.path).query)
self.server.authorization_code = qs['code'][0]
@@ -82,4 +90,4 @@ class SimpleOAuthAuthenticator(object):
return self._get_tokens(authorization_code=authorization_code)
def get_refreshed_token(self, refresh_token):
- return self._get_tokens(refresh_token=refresh_token, grant_type="refresh_token")
+ return self._get_tokens(refresh_token=refresh_token, grant_type="refresh_token") \ No newline at end of file