- We checked access token is formatted correctly and was obtained using a Connected App that includes the pardot_api OAuth scope
- Also checked the user associated with the token is synced to the Pardot business unit
- We also check the token used is within its expiration time.
But we still keep getting this error in Postman:
{
"@attributes": {
"stat": "fail",
"version": 1,
"err_code": 184
},
"err": "access_token is invalid, unknown, or malformed: Invalid scope"
}
And we also have a Python script that gives us the same issue and at one point it used to work - what is something we are not accounting for:
# auth headers
auth_header = {
'Pardot-Business-Unit-Id': pardot_business_unit_id,
'Authorization': f"Bearer {access_token}"
}
try:
pardot_request = r.get(
url= f"https://pi.pardot.com/api/{object_name}/version/4/do/query?format=json",
headers = {
'Pardot-Business-Unit-Id': pardot_business_unit_id,
'Authorization': f"Bearer {access_token}"
}
)
# Convert JSON string to JSON object
json_object = json.loads(pardot_request.text)
print(json_object)
data_dict = json_object['result'][object_name]
df = pd.DataFrame(data_dict)
print(df.shape)
return df
except Exception as e:
print(e.trace)
Hi !
In the Oauth policies of your Connected App, do you have "All Users may self-authorize" in Permitted Users and "Relax IP restrictions" in "IP Relaxation"?
The Oauth should be "Manage Pardot Services (pardot_api)", is this what you have?
Hope this helps 😎
#SharingIsLearning #AccountEngagement
François.
PS : In order other Trailblazers to be pointed directly the correct answer, please do not forget to click “Accept this answer” below the correct one.