I am trying to send a POST request in order to receive an Access Token in return.
The documentation is as follows:
Client Credentials
This is your first route to obtain an access_token to communicate with the API.
Route : POST https://api.helloasso.com/oauth2/token
Headers
Content-Type = application/x-www-form-urlencoded
Body
client_id = Your Client Id
client_secret = Your Client Secret
grant_type = client_credentials
Solution I tried
Based on this post, I tried the following code:
function qwe() { const url = 'https://api.helloasso.com/oauth2/token'; const headers = { "client_id": "Your Client Id", "client_secret": "Your Client Secret", "grant_type": "client_credentials" }; const options = { 'method' : 'post', 'contentType': 'application/x-www-form-urlencoded', 'headers': headers }; const response = UrlFetchApp.fetch(url, options); var data = JSON.parse(response); Logger.log(data); } Upon running this, I get an error "Exception: Request failed for https://api.helloasso.com returned code 400. Truncated server response: {"error":"unauthorized_client","error_description":"client_id is not set"}".
I am a beginner, and would appreciate any help on this! Thank you in advance
https://api.helloasso.combecause this looks like it needs the Client ID to complete the authorization