mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2024-12-25 17:42:24 +00:00
Authenticate to Hello Asso by client id and secret
This commit is contained in:
parent
f7d52aa6da
commit
f8d38738ea
@ -10,6 +10,17 @@ import requests
|
|||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
def handle(self, *args, **options): # noqa: C901
|
def handle(self, *args, **options): # noqa: C901
|
||||||
|
# Get access token
|
||||||
|
response = requests.post('https://api.helloasso.com/oauth2/token', headers={
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
}, data={
|
||||||
|
'client_id': os.getenv('HELLOASSO_CLIENT_ID', ''),
|
||||||
|
'client_secret': os.getenv('HELLOASSO_CLIENT_SECRET', ''),
|
||||||
|
'grant_type': 'client_credentials',
|
||||||
|
}).json()
|
||||||
|
|
||||||
|
token = response['access_token']
|
||||||
|
|
||||||
organization = "animath"
|
organization = "animath"
|
||||||
form_slug = "tfjm-2021"
|
form_slug = "tfjm-2021"
|
||||||
from_date = "2000-01-01"
|
from_date = "2000-01-01"
|
||||||
@ -17,7 +28,7 @@ class Command(BaseCommand):
|
|||||||
f"?from={from_date}&pageIndex=1&pageSize=10000&retrieveOfflineDonations=false"
|
f"?from={from_date}&pageIndex=1&pageSize=10000&retrieveOfflineDonations=false"
|
||||||
headers = {
|
headers = {
|
||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
"Authorization": f"Bearer {os.getenv('HELLO_ASSO_TOKEN', '')}",
|
"Authorization": f"Bearer {token}",
|
||||||
}
|
}
|
||||||
http_response = requests.get(url, headers=headers)
|
http_response = requests.get(url, headers=headers)
|
||||||
response = http_response.json()
|
response = http_response.json()
|
||||||
|
Loading…
Reference in New Issue
Block a user