getting an oath token using curl
I am attempting to write a tiny app to download my club's calendar from wild apricot. I plan to write this in python 3, triggered by cron. The first step is to get an oauth token. As a test I tried the following curl command but I receive a 401/unauthorized error. Please note that XXXXX is not my real application ID :-)
I tried variations, and also some similar code in python with the same result.
Any hints?
curl -v -H 'Authorization: Basic BASE64ENCODED("XXXXX")' -H 'Content-Type: application/json' -H 'Transfer-Encoding: chunked' -d '{"granttype":"client_credentials", "scope":"auto"}' https://oauth.wildapricot.org/auth/token
Here is an example
1 Build your Authorization header.
– Assume you API key is b8gxv-njhci-XXXXXXXXXXXX-50
– encode the line “APIKEY:b8gxv-njhci-XXXXXXXXXXXX-50”, you will get
“QVBJS0VZOmI4Z3h2LW5qaGNpLVhYWFhYWFhYWFhYWC01MA==”
2 use this value to make a call
curl -X POST \
https://oauth.wildapricot.org/auth/token \
-H ‘Authorization: Basic QVBJS0VZOmI4Z3h2LW5qaGNpLVhYWFhYWFhYWFhYWC01MA==’ \
-H ‘Content-Type: application/x-www-form-urlencoded’ \
-d ‘scope=auto&grant_type=client_credentials’
==
I recommend to use POSTMAN before writing any code.