Only define token_url once
This commit is contained in:
parent
7ae0714c73
commit
d790197e19
|
@ -15,13 +15,13 @@ hub:
|
||||||
import requests
|
import requests
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from oauthenticator.generic import GenericOAuthenticator
|
from oauthenticator.generic import GenericOAuthenticator
|
||||||
|
token_url = 'https://' + os.environ['NEXTCLOUD_HOST'] + '/index.php/apps/oauth2/api/v1/token'
|
||||||
|
|
||||||
def get_nextcloud_access_token(refresh_token):
|
def get_nextcloud_access_token(refresh_token):
|
||||||
debug = 'NEXTCLOUD_DEBUG_OAUTH' in os.environ
|
debug = 'NEXTCLOUD_DEBUG_OAUTH' in os.environ
|
||||||
client_id = os.environ['NEXTCLOUD_CLIENT_ID']
|
client_id = os.environ['NEXTCLOUD_CLIENT_ID']
|
||||||
client_secret = os.environ['NEXTCLOUD_CLIENT_SECRET']
|
client_secret = os.environ['NEXTCLOUD_CLIENT_SECRET']
|
||||||
|
|
||||||
url = 'https://' + os.environ['NEXTCLOUD_HOST'] + '/index.php/apps/oauth2/api/v1/token'
|
|
||||||
code = refresh_token
|
code = refresh_token
|
||||||
data = {
|
data = {
|
||||||
'grant_type': 'refresh_token',
|
'grant_type': 'refresh_token',
|
||||||
|
@ -30,7 +30,7 @@ hub:
|
||||||
'client_id': client_id,
|
'client_id': client_id,
|
||||||
'client_secret': client_secret
|
'client_secret': client_secret
|
||||||
}
|
}
|
||||||
response = requests.post(url, data=data)
|
response = requests.post(token_url, data=data)
|
||||||
if debug:
|
if debug:
|
||||||
print(response.text)
|
print(response.text)
|
||||||
return response.json()
|
return response.json()
|
||||||
|
@ -102,7 +102,7 @@ hub:
|
||||||
c.NextcloudOAuthenticator.username_claim = lambda r: r.get('ocs', {}).get('data', {}).get('id')
|
c.NextcloudOAuthenticator.username_claim = lambda r: r.get('ocs', {}).get('data', {}).get('id')
|
||||||
c.NextcloudOAuthenticator.userdata_url = 'https://' + os.environ['NEXTCLOUD_HOST'] + '/ocs/v2.php/cloud/user?format=json'
|
c.NextcloudOAuthenticator.userdata_url = 'https://' + os.environ['NEXTCLOUD_HOST'] + '/ocs/v2.php/cloud/user?format=json'
|
||||||
c.NextcloudOAuthenticator.authorize_url = 'https://' + os.environ['NEXTCLOUD_HOST'] + '/index.php/apps/oauth2/authorize'
|
c.NextcloudOAuthenticator.authorize_url = 'https://' + os.environ['NEXTCLOUD_HOST'] + '/index.php/apps/oauth2/authorize'
|
||||||
c.NextcloudOAuthenticator.token_url = 'https://' + os.environ['NEXTCLOUD_HOST'] + '/index.php/apps/oauth2/api/v1/token'
|
c.NextcloudOAuthenticator.token_url = token_url
|
||||||
c.NextcloudOAuthenticator.oauth_callback_url = 'https://' + os.environ['JUPYTER_HOST'] + '/hub/oauth_callback'
|
c.NextcloudOAuthenticator.oauth_callback_url = 'https://' + os.environ['JUPYTER_HOST'] + '/hub/oauth_callback'
|
||||||
c.NextcloudOAuthenticator.allow_all = True
|
c.NextcloudOAuthenticator.allow_all = True
|
||||||
c.NextcloudOAuthenticator.refresh_pre_spawn = True
|
c.NextcloudOAuthenticator.refresh_pre_spawn = True
|
||||||
|
|
Loading…
Reference in a new issue