Reputation: 1
we got the app approved and the token is generated with the user authentication. we even specified all the necessary scopes information during the authorization process. I am trying to read the advertiser and campaign information using the token but getting the following error
Sample Python code:
class BearerAuth(requests.auth.AuthBase):
def __init__(self, token):
self.token = token
def __call__(self, r):
r.headers["authorization"] = "Bearer " + self.token
return r
token=<token>
url='https://api.pinterest.com/ads/v3/advertisers/me/'
Advertisers = requests.get(url, auth=BearerAuth(token))
print(Advertisers.json())
response:
{'error': {'message': 'None'}, 'code': 3, 'data': None, 'message': 'Authorization failed.', 'endpoint_name': 'ads_v3_get_advertiser_handler', 'status': 'failure'}
this is the curl command that I used to generate the token.
curl -X PUT --url https://api.pinterest.com/v3/oauth/access_token/ --header "Authorization: Basic <base 64 encoded id:secret>" --data "code=<codeobtaineduponaccess>&redirect_uri=<redirecturl>&grant_type=authorization_code
do i need to add the scope information in the above command as well or is it not necessary. what am i doing wrong? can someone please explain it to me.
Note: I am able to read the user related information using the token. I am not able to access only the read_advertisers, read_campaigns scopes.
Thanks
Upvotes: 0
Views: 783
Reputation: 1
In principle you do not need to specify the scope as Pinterest says:
By default when a user grants access to your app you will receive an access token with all possible scopes allowed for your app.
If I am not mistaken you can view all the scopes your user has access to in the response to this end-point:
https://www.pinterest.com/oauth/?client_id={app_id}&redirect_uri={redirect_uri}&response_type=code&state={optional}
Be careful not to specify a scope when calling this endpoint as it can only reduce the scopes you will have access to since no scope means all scope.
Hope that makes sense,
Henri
Upvotes: 0