I am trying to get a list of YouTube-videos using the Skybrud Social 1.0.1 package for Umbraco. Right now I am getting an "insufficient permission"-error even trying to list channels of a user. I think that I might need to specify a permission scope in code. Maybe something like this?
var scope = new Skybrud.Social.Google.OAuth.GoogleScopeCollection();
scope.Add(Skybrud.Social.Google.YouTube.YouTubeScopes.Readonly);
This is my code so far
@using Skybrud.Social
@using Skybrud.Social.Google
@using Skybrud.Social.Umbraco.Google.PropertyEditors.OAuth
var rootNode = Model.Content.AncestorOrSelf(1);
var oAuth = rootNode.GetPropertyValue<GoogleOAuthData>("googleOauth");
if (oAuth != null && oAuth.IsValid)
{
GoogleService googleService = oAuth.GetService();
var channelOptions = new Skybrud.Social.Google.YouTube.Options.YouTubeChannelListOptions()
{
Username = "xxx"
};
var response = googleService.YouTube.Channels.GetChannels(channelOptions);
}
If we look at Skybrud.Social for Umbraco 7 and Skybrud.Social as two separate packages, Skybrud.Social is shortly described the mapping to various APIs as well as logic for authentication, while Skybrud.Social for Umbraco 7 is an integration between Umbraco and a portion of Skybrud.Social.
Turns out read-only access to videos in a channel was all I needed. Because of this I ended up fetching the YouTube channel feed as JSON using the API-key approach. Keeping it simple :-)
YouTube list of videos
I am trying to get a list of YouTube-videos using the Skybrud Social 1.0.1 package for Umbraco. Right now I am getting an "insufficient permission"-error even trying to list channels of a user. I think that I might need to specify a permission scope in code. Maybe something like this?
This is my code so far
Hi Morten,
If we look at Skybrud.Social for Umbraco 7 and Skybrud.Social as two separate packages, Skybrud.Social is shortly described the mapping to various APIs as well as logic for authentication, while Skybrud.Social for Umbraco 7 is an integration between Umbraco and a portion of Skybrud.Social.
Skybrud.Social for Umbraco 7 has a property editor (the one you're using) that's lets you authenticate with Google, but this property will only request basic Google scopes, and therefore not any scopes for YouTube. So you will have to implement your own authentication page. I'm a little behind on the documentation for this part, so you can use this class for inspiration: https://github.com/abjerner/Skybrud.Social.Umbraco/blob/master/src/Skybrud.Social.Umbraco/App_Plugins/Skybrud.Social/Dialogs/GoogleOAuth.aspx.cs the scope is specified around line 125 ;)
With the proper scope (like
YouTubeScopes.Readonly
from your example), you should be able to execute your second example ;)Turns out read-only access to videos in a channel was all I needed. Because of this I ended up fetching the YouTube channel feed as JSON using the API-key approach. Keeping it simple :-)
is working on a reply...