Just like other quickstart using Youtube API, you must also follow the steps on how to obtain your client_secret.json
that contains your token_uri
:
- Use this wizard to create or select a project in the Google Developers Console and automatically turn on the API. Click Continue,
then Go to credentials.
- On the Add credentials to your project page, click the Cancel button.
- At the top of the page, select the OAuth consent screen tab. Select an Email address, enter a Product name if not already set, and click
the Save button.
- Select the Credentials tab, click the Create credentials button and select OAuth client ID.
- Select the application type Other, enter the name "YouTube Data API Quickstart", and click the Create button.
- Click OK to dismiss the resulting dialog.
- Click the download icon (Donwload JSON) button to the right of the client ID.
- Move the downloaded file to your working directory and rename it
client_secret.json
.
client_secret.json
{"installed":{"client_id":"837380381682-kthu0nva0f5tqli35o6hk4jiv0p9mh3s.apps.googleusercontent.com","project_id":"sureness-1534400441179","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://www.googleapis.com/oauth2/v3/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"n-5X4ssSnqw9JXFOrLAl1J1y","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","http://localhost"]}}
This is a code snippet from .Net Code Sample where client_secrets.json
was implemented:
UserCredential credential;
using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read))
{
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
// This OAuth 2.0 access scope allows for full read/write access to the
// authenticated user's account.
new[] { YouTubeService.Scope.Youtube },
"user",
CancellationToken.None,
new FileDataStore(this.GetType().ToString())
);
}