Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Using YouTube Content ID API with Service Account authentication

We are using the YouTube Content ID API with OAUTH 2.0 client id authentication, it's a bit messy using

InstalledAppFlow but it works fine. We are switching to a service account authentication, to simplify things. We created a service account, with a JSON key and we are receiving the error HttpStatus 403 Forbidden when trying to use an endpoint from YouTube Content ID API. We need to grant a special role or permission to the service account?

 

HttpError: <HttpError 403 when requesting https://www.googleapis.com/youtube/partner/v1/assets?id=xxxx&onBehalfOfContentOwner=yyyy&alt=json returned "Forbidden">

 

Code used for the example:

 

from google.oauth2.service_account import Credentials as ServiceAccountCredentials
from googleapiclient import discovery

secrets_file = "keys.json"
service_name = "youtubePartner"
service_version = "v1"
scopes = ["https://www.googleapis.com/auth/youtubepartner"]
credentials = ServiceAccountCredentials.from_service_account_file(
    secrets_file,
    scopes=scopes,
)
api = discovery.build(
    service_name,
    service_version,
    credentials=credentials,
    cache_discovery=False,
)
response = api.assets().list(id="xxxx", onBehalfOfContentOwner="yyyy").execute()

 

Solved Solved
0 1 83
1 ACCEPTED SOLUTION

@hyper7 thanks for your question!

This forum is all about Application Integration. We recommend exploring other Google Cloud forums for more tailored guidance on your specific question, please feel free to reach out if you'd like to explore how Application Integration can help streamline your projects! 😉

View solution in original post

1 REPLY 1

@hyper7 thanks for your question!

This forum is all about Application Integration. We recommend exploring other Google Cloud forums for more tailored guidance on your specific question, please feel free to reach out if you'd like to explore how Application Integration can help streamline your projects! 😉