-
-
Save kperry2215/3bb97309eb4b1730c00e9d4b18918876 to your computer and use it in GitHub Desktop.
import requests | |
r= requests.post(url = "https://auth.accela.com/oauth2/token", | |
headers={"Content-Type": "application/x-www-form-urlencoded", | |
"x-accela-appid": str(client_id)}, | |
data = {"grant_type" :"password", | |
"client_id": str(client_id), | |
"client_secret": str(client_secret), | |
"redirect_uri": "http://localhost/myapp/", | |
"username": username, | |
"password": password, | |
"environment": "PROD", | |
"scope": "records"}, verify=False).json() | |
agencies = requests.get("https://apis.accela.com/v4/agencies", | |
headers={"Authorization": r['access_token']}, verify=False).json() | |
# Loop through the agencies and get the records??? | |
for agency in agencies['result']: | |
req = requests.get("https://apis.accela.com/v4/records", | |
headers={'x-accela-appid': str(client_id), | |
'x-accela-agency': agency['name'], | |
"Authorization": r['access_token']}, | |
verify=False) | |
print(req.status_code) | |
@clay-jacob I get the following output for ls.content:
{'access_token': 'ACCESS_TOKEN',
'token_type': 'bearer',
'expires_in': 900,
'refresh_token': 'REFRESH_TOKEN',
'scope': 'records'}
I didn't sign up specifically for Baker City when I made a public account. I signed up for Denver here: https://aca-prod.accela.com/DENVER/Default.aspx. However, even if I use "DENVER" instead of "BAKER_CITY" above as agency_name, I get the 500 internal server error. Am I not using the right site for signing up for a public user account? Is there somewhere in the documentation on all of the accounts I need to sign up for? Perhaps that's my issue.
I would like to pull data for multiple agencies as well. Is that not possible with the current setup, or can I make multiple accounts with the same email, etc?
@clay-jacob I have solved the issue! I did not link to my Denver account in the Accela Civic Portal. Once I did, I was able to successfully pull data. Thank you for pointing me in the right direction!
Hi @kperry2215 , I have a similar issue. Would you mind a brief explanation on how to link my account to an agency? Do you have the link? Thank you.
can you add
print(ls.content)
and let me know the output? Is Baker City the agency you made your public user account with?