Hi! I am having the following issue when trying to download admob's report using its API.
First I need to retrieve the publisher_id for some business reason, and I am using the following method:
- service.accounts().list(pageSize=1).execute()["account"]
where service is created as shown below:
from googleapiclient.discovery import build
from google.oauth2.credentials import Credentials
credentials = Credentials(**creds_dict)
service = build(
"admob", "v1", credentials=credentials, cache_discovery=False, num_retries=5
)
The process runs ok 90% of the times, but sometimes it fails with the following error.
google_auth_httplib2.request: Refreshing credentials due to a 401 response. Attempt 1/2.
[WARNING] | googleapiclient.http._should_retry_response: Encountered 403 Forbidden with reason "PERMISSION_DENIED"
In some cases it might works after 15 retries more or less, but I cant figure out the main reason of this behaviour.
Any idea? Thanks in advance!