Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Morten B 13 posts 66 karma points
    Oct 28, 2015 @ 10:50
    Morten B
    0

    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?

    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);
        }
    
  • Anders Bjerner 487 posts 2989 karma points MVP 7x admin c-trib
    Oct 28, 2015 @ 22:38
    Anders Bjerner
    100

    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 ;)

  • Morten B 13 posts 66 karma points
    Oct 29, 2015 @ 20:28
    Morten B
    0

    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 :-)

Please Sign in or register to post replies

Write your reply to:

Draft