Use OAuth 2.0 for Service Accounts
Stay organized with collections
Save and categorize content based on your preferences.
Note:The YouTube Content ID API is intended for use by YouTube content partners and is not accessible to all developers or to all YouTube users. If you do not see the YouTube Content ID API as one of the services listed in the Google API Console
, see the YouTube Help Center
to learn more about the YouTube Partner Program.
Background
A service account
is a Google Account that can be used to authorize API calls without any user interaction. Unlike the other OAuth 2.0 flows, authenticating and authorizing access using the OAuth 2.0 for service accounts flow
does not take place in a web browser. Instead, OAuth 2.0 for service accounts relies on cryptographic signatures to authorize access. As long as your code has access to the underlying cryptographic key, it can continue making API calls without worrying about refresh and access tokens. It's perfect for automated applications running on servers without human intervention.
You can now use the OAuth 2.0 for service accounts flow to authorize YouTube Content ID API requests. You can also use this flow to authorize YouTube Data API and YouTube Analytics API calls to methods that support delegation parameters
. In all of these cases, an application using this flow is authorizing the API request as a YouTube Content Partner (using a YouTube CMS account) rather than as a YouTube channel owner.
Set up your service account
The following screenshots illustrate the process of creating a service account associated with your API Project, which you should ensure already has the appropriate APIs (YouTube Data API v3, YouTube Analytics API, YouTube Content ID API, etc.) enabled.
- Visit https://cloud.google.com/console
and choose your existing API Project (or create a new one).
- In the sidebar on the left, select APIs & auth
.
- Make sure the YouTube Content ID API is activated for your project.
- In the sidebar on the left, select Credentials
.
- Click the Create new client ID
button.
- Choose Service account
from the listed options and click Create client ID
. The private key for your service account will be downloaded to your machine. This is the only copy of the key and you need to save the key in a secure location that your application can read from.
- Make note of the email address for the service account. (The email address appears on the Credentials
page.) You will need the address to grant your service account the ability to access your YouTube CMS account.
- Visit https://www.youtube.com/content_owner_users
and click the New user
button.
- Enter the email address of the service account from step 7
in the Email address
field and choose the appropriate role for the user. Then click the Invite
button.
- Your service account automatically accepts the invitation, and that account can subsequently access the YouTube APIs acting on behalf of your YouTube CMS account.
- Follow the instructions for the OAuth 2.0 service account flow in the authorizing requests
guide to authorize requests using your service account.
Make API Calls
Most languages' client libraries
have native support for the OAuth 2.0 for service account flow. You should be able to follow the examples in the library's documentation to perform basic authorization with the appropriate YouTube API scopes.
The most important thing to keep in mind is that you must use the appropriate delegation parameters
to act on behalf of a given channel linked to your CMS account. To view a list of channels linked to your CMS account, visit https://cms.youtube.com/edit_user_accounts
.
All rights reserved. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-28 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[[["\u003cp\u003eThe YouTube Content ID API is only available to YouTube content partners and is not accessible to all developers or YouTube users.\u003c/p\u003e\n"],["\u003cp\u003eService accounts are Google Accounts used to authorize API calls without user interaction, relying on cryptographic signatures for authentication, making them suitable for automated applications.\u003c/p\u003e\n"],["\u003cp\u003eYou can authorize YouTube Content ID, Data, and Analytics API requests using the OAuth 2.0 service accounts flow as a YouTube Content Partner, not as a YouTube channel owner.\u003c/p\u003e\n"],["\u003cp\u003eTo set up a service account, you need to create a new client ID, choose the 'service account' option, download the private key, and grant the account access to your YouTube CMS account.\u003c/p\u003e\n"],["\u003cp\u003eWhen making API calls, ensure you use appropriate delegation parameters to act on behalf of a specific channel linked to your CMS account, as opposed to a personal YouTube channel.\u003c/p\u003e\n"]]],["To use the YouTube Content ID API, create a service account in the Google API Console. Enable the necessary YouTube APIs for your project. Download the private key and save it securely. Grant the service account access to your YouTube CMS account by inviting its email address as a new user with a designated role. Then, use the OAuth 2.0 service account flow, along with delegation parameters, to authorize API calls. Use client libraries to authenticate and act on behalf of linked channels.\n"],null,["# Use OAuth 2.0 for Service Accounts\n\n**Note:** The YouTube Content ID API is intended for use by YouTube content partners and is not accessible to all developers or to all YouTube users. If you do not see the YouTube Content ID API as one of the services listed in the [Google API Console](https://console.cloud.google.com/), see the [YouTube Help Center](https://support.google.com/youtube/answer/72851) to learn more about the YouTube Partner Program.\n\nBackground\n----------\n\nA [service account](https://googledevelopers.blogspot.com/2012/03/service-accounts-have-arrived.html) is a Google Account that can be used to authorize API calls without any user interaction. Unlike the other OAuth 2.0 flows, authenticating and authorizing access using the [OAuth 2.0 for service accounts flow](/identity/protocols/oauth2/service-account) does not take place in a web browser. Instead, OAuth 2.0 for service accounts relies on cryptographic signatures to authorize access. As long as your code has access to the underlying cryptographic key, it can continue making API calls without worrying about refresh and access tokens. It's perfect for automated applications running on servers without human intervention.\n\nYou can now use the OAuth 2.0 for service accounts flow to authorize YouTube Content ID API requests. You can also use this flow to authorize YouTube Data API and YouTube Analytics API calls to methods that support [delegation parameters](/youtube/partner/identify_content_owner). In all of these cases, an application using this flow is authorizing the API request as a YouTube Content Partner (using a YouTube CMS account) rather than as a YouTube channel owner.\n\nSet up your service account\n---------------------------\n\nThe following screenshots illustrate the process of creating a service account associated with your API Project, which you should ensure already has the appropriate APIs (YouTube Data API v3, YouTube Analytics API, YouTube Content ID API, etc.) enabled.\n\n1. Visit \u003chttps://cloud.google.com/console\u003e and choose your existing API Project (or create a new one).\n2. In the sidebar on the left, select **APIs \\& auth**.\n3. Make sure the YouTube Content ID API is activated for your project.\n4. In the sidebar on the left, select **Credentials**.\n5. Click the **Create new client ID** button.\n6. Choose **Service account** from the listed options and click **Create client ID**. The private key for your service account will be downloaded to your machine. This is the only copy of the key and you need to save the key in a secure location that your application can read from.\n7. Make note of the email address for the service account. (The email address appears on the **Credentials** page.) You will need the address to grant your service account the ability to access your YouTube CMS account.\n8. Visit \u003chttps://www.youtube.com/content_owner_users\u003e and click the **New user** button.\n9. Enter the email address of the service account from [step 7](#step7) in the **Email address** field and choose the appropriate role for the user. Then click the **Invite** button.\n10. Your service account automatically accepts the invitation, and that account can subsequently access the YouTube APIs acting on behalf of your YouTube CMS account.\n11. Follow the instructions for the OAuth 2.0 service account flow in the [authorizing requests](/youtube/partner/guides/auth) guide to authorize requests using your service account.\n\nMake API Calls\n--------------\n\nMost languages' [client libraries](/accounts/docs/OAuth2ServiceAccount#libraries) have native support for the OAuth 2.0 for service account flow. You should be able to follow the examples in the library's documentation to perform basic authorization with the appropriate YouTube API scopes.\n\nThe most important thing to keep in mind is that you must use the appropriate [delegation parameters](/youtube/partner/identify_content_owner) to act on behalf of a given channel linked to your CMS account. To view a list of channels linked to your CMS account, visit \u003chttps://cms.youtube.com/edit_user_accounts\u003e."]]