Empty response for data studio assets search API

Viewed 345

I am trying to fetch the data studio assets to manage the permissions based on that data through APIs. I am using oAuth2 access token generated using the service account as I want to automate this process and not rely on user consent for authorization every time. oAuth2 authorization using service account

Steps I have followed:

Using the following snippet to generate the signed JWT.

import jwt
import time
import json
import requests

iat = int(time.time())
exp = iat + 3600

claim_set = {"iss": "datastudio-manager@data-project.iam.gserviceaccount.com",
             "scope": "https://www.googleapis.com/auth/datastudio https://www.googleapis.com/auth/datastudio.readonly https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile openid",
             "aud": "https://oauth2.googleapis.com/token", "exp": exp, "iat": iat}

encoded = jwt.encode(claim_set, private_key, algorithm="RS256")

response = requests.post("https://oauth2.googleapis.com/token", params={
    "grant_type": "urn:ietf:params:oauth:grant-type:jwt-bearer",
    "assertion": encoded
})

print(response.json()["access_token"])

Using token generated from above step to make API call.

curl -H "Authorization: Bearer <access_token>" https://datastudio.googleapis.com/v1/assets:search?assetTypes=report

Response of the above request is {} with status 200 and when I am trying to view permissions for a particular asset it is giving me the following response.

API endpoint: https://datastudio.googleapis.com/v1/assets/<asset_id>/permissions

{
    "error": {
        "code": 403,
        "message": "The caller does not have permission",
        "status": "PERMISSION_DENIED"
    }
}

Is authentication using access token generated through the above oAuth2 method supported for Data studio APIs?

Any leads are much appreciated, thanks in advance!

0 Answers
Related