Verified Commit fe55a2a5 authored by ynerant's avatar ynerant
Browse files

Don't hardcode OAuth2 parameters

parent cdcb743b
Pipeline #9544 passed with stages
in 2 minutes and 48 seconds
......@@ -167,22 +167,26 @@ PAGINATION_NUMBER = 25
AUTH_USER_MODEL = 'users.User'
# AUTHLIB CLIENTS
NOTE_KFET_URL = 'https://note.crans.org'
NOTE_KFET_CLIENT_ID = 'CHANGE_ME'
NOTE_KFET_CLIENT_SECRET = 'CHANGE_ME'
NOTE_KFET_SCOPES = '1_1 2_1 48_1'
try:
from .settings_local import *
except ImportError:
pass
AUTHLIB_OAUTH_CLIENTS = {
'notekfet': {
'client_id': 'qtElmOUj67YNvSZjA5l70ITUMxd3NJ9kksBsK5e9',
'client_secret': 'SwF909sLIeU5GhruXsFzKfdBhFNgs8nvkVpFKgP4pIQ80BmLLlf3ZkMoNL7Cpox6Ke3MXNWGswTtbKkM8AiB9v6pys8PNfYH0MDFWAi3tnffjwaMQBzRFhjx20qb6S4W',
'access_token_url': 'https://note-dev.crans.org/o/token/',
'refresh_token_url': 'https://note-dev.crans.org/o/token/',
'authorize_url': 'https://note-dev.crans.org/o/authorize/',
'userinfo_endpoint': 'https://note-dev.crans.org/api/me/',
'client_id': f'{NOTE_KFET_CLIENT_ID}',
'client_secret': f'{NOTE_KFET_CLIENT_SECRET}',
'access_token_url': f'{NOTE_KFET_URL}/o/token/',
'refresh_token_url': f'{NOTE_KFET_URL}/o/token/',
'authorize_url': f'{NOTE_KFET_URL}/o/authorize/',
'userinfo_endpoint': f'{NOTE_KFET_URL}/api/me/',
'client_kwargs': {
'scope': '1_1 2_1 48_1',
'scope': NOTE_KFET_SCOPES,
}
}
}
try:
from .settings_local import *
except ImportError:
pass
......@@ -40,3 +40,8 @@ DATABASES = {
'PORT': '',
}
}
NOTE_KFET_URL = 'https://note.crans.org'
NOTE_KFET_CLIENT_ID = 'CHANGE_ME'
NOTE_KFET_CLIENT_SECRET = 'CHANGE_ME'
NOTE_KFET_SCOPES = '1_1 2_1 48_1'
......@@ -178,7 +178,7 @@ class AccessToken(models.Model):
Extract information about the Note Kfet API by using the current
access token.
"""
data = requests.get('https://note-dev.crans.org/api/me/',
data = requests.get(f'{settings.NOTE_KFET_URL}/api/me/',
headers=self.auth_header()).json()
username = data['username']
email = data['email']
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment