'Getting "Authentication failed" error while pulling data from Pinterest through API

I am getting an "Authentication failed." error while pulling data from Pinterest through the API method. I have followed Pinterest Docs for creating an app and generating access_token. I have successfully generated access token. But when I ran my code I am getting "Authentication failed" error. Here is my code.

import requests
access_token='pina_*********'  ## my acces code goes here
params = {'access_token':access_token,'fields':'ad_account_id'}

headers = {"Accept": "application/json"}
res = requests.request('GET',url = 'https://api.pinterest.com/v5/user_account',params=params,headers=headers)

print(res.text)

I getting output as:

{"code":2,"message":"Authentication failed."}

Can anyone suggest me what might be the reason for the error.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source