When trying to query Google Firebase dynamic link stats I am getting an empty object.
I've got 5 dynamic links in the firebase console which were created via the console. Using the following code I am able to get a token. I used the GCP->IAM->Service Accounts to create a new account and pull down the JSON file. I've ensured the project_id matches the one in firebase.
link = "my_dynamic_link_short_name"
scopes = ["https://www.googleapis.com/auth/firebase"]
credentials = service_account.Credentials.from_service_account_file("key.json", scopes=scopes)
url_base = "https://firebasedynamiclinks.googleapis.com/v1/SHORT_DYNAMIC_LINK/linkStats?durationDays=1"
encoded_link = urllib.parse.quote(link, safe='')
url = url_base.replace('SHORT_DYNAMIC_LINK', encoded_link)
request = Request()
credentials.refresh(request)
access_token = credentials.token
HEADER = {"Authorization": "Bearer " + access_token}
response = requests.get(url, headers=HEADER)
print(response.json())
Both of the above requests return a 200 but no data returned.
The GCP service account I am using has the following roles:
- Firebase Admin
- Firebase Admin SDK Administrator Service Agent
- Service Account Token Creator
I've given it full owner to test and it didn't resolve issue.
from Query Firebase dynamic link information
No comments:
Post a Comment