The page has been marked as outdated. This generally means that the page was written for either a previous version of the package or a previous version of the underlying API(s).

Scope

The YouTube API defines a few scopes. Each scope will define the permissions your app will have to the account of the authenticated user.

Skybrud.Social Name Description
YouTubeScopes.Manage https://www.googleapis.com/auth/youtube Manage your YouTube account.
YouTubeScopes.Readonly https://www.googleapis.com/auth/youtube.readonly View your YouTube account.
YouTubeScopes.Upload https://www.googleapis.com/auth/youtube.upload Upload YouTube videos and manage your YouTube videos.
YouTubeScopes.PartnerChannelAudit https://www.googleapis.com/auth/youtubepartner-channel-audit Retrieve the auditDetails part in a channel resource.

In addition to the scopes listed above, Google also also has few global scopes.

Working with scopes in code

Scopes for the YouTube API are implemented by the YouTubeScope class, which again inherits from GoogleScope. A list of known scopes are available through either the YouTubeScopes or GoogleScopes classes.

When setting up the code for an authentication page, you must specify the scopes through an instance of GoogleScopeCollection. There are a couple of different ways to create an instance of this calls, so see the snippet below for examples:

// We can initialize a new collection based on one or more scopes
GoogleScopeCollection scopes1 = new GoogleScopeCollection(GoogleScopes.Email, GoogleScopes.Profile);

// We can also initialize a new empty collection, and then add scopes manually
GoogleScopeCollection scopes2 = new GoogleScopeCollection();

// Add scopes one by one
scopes2.Add(GoogleScopes.Email);
scopes2.Add(GoogleScopes.Profile);
scopes2.Add(YouTubeScopes.Readonly);

// Remove the "email" scope if contained in the collection
if (scopes2.Contains(GoogleScopes.Email)) {
    scopes2.Remove(GoogleScopes.Email);
}

// Or just remove a scope without checking first
scopes2.Remove(GoogleScopes.OpenId);

// With help of operator overloading, initialize a new collection from a single scope
GoogleScopeCollection scopes3 = GoogleScopes.Profile;

// Also with help of operator overloading, two scopes added together results in a new collection
GoogleScopeCollection scopes4 = GoogleScopes.Profile + YouTubeScopes.Readonly;

References