Search code examples
google-apiyoutube-apixamarin.formsportable-class-librarygoogle-api-dotnet-client

How to upload videos to YouTube [Xamarin.Forms (Portable) ]


I am trying to upload videos to YouTube but somehow it's not working in Xamarin.Forms (Portable) project. Is there any way to upload the Videos in YouTube through Xamarin.Forms (Portable)

var initializer = new GoogleAuthorizationCodeFlow.Initializer
{
    ClientSecrets = new ClientSecrets
    {
        ClientId = Constants.API.Google.ClientID,
        ClientSecret = Constants.API.Google.ClientSecret
    },
    Scopes = new[] { YouTubeService.Scope.Youtube }
};
var flow = new AuthorizationCodeFlow(initializer);
TokenResponse token = flow.LoadTokenAsync("user", CancellationToken.None).Result;

but every time I am getting null in TokenResponse token, I am not sure what should I pass in place of user in flow.LoadTokenAsync("user", CancellationToken.None)

Thank You.


Solution

  • As I had feared the Google .Net client library does not currently support Xamarin. Please see issue: Unable to Google.Apis.Auth.PlatformServices in Xamarin.Forms

    It's because GoogleWebAuthorizationBroker requires several classes from Google.Apis.Auth.PlatformServices, and Google.Apis.Auth.PlatformServices is not compatible with Xamarin.