1

我想上傳視頻到YouTube,但不知何故它不在Xamarin.Forms (Portable)項目工作。有沒有辦法通過Xamarin.Forms (Portable)如何上傳視頻到YouTube [Xamarin.Forms(便攜式)]

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; 

但每次我在TokenResponse token越來越空,上傳0​​的影片,我不知道我應該在的地方user傳遞flow.LoadTokenAsync("user", CancellationToken.None)

謝謝。

+0

我建議你在客戶端庫上發佈這個問題。 https://github.com/google/google-api-dotnet-client/issues – DaImTo

回答

1

因爲我擔心Google .Net客戶端庫目前不支持Xamarin。請參閱問題:Unable to Google.Apis.Auth.PlatformServices in Xamarin.Forms

這是因爲GoogleWebAuthorizationBroker需要從Google.Apis.Auth.PlatformServices幾類,Google.Apis.Auth.PlatformServices不與Xamarin兼容。

+0

那麼,有沒有其他方法可以做到這一點? –

+0

未使用官方客戶端庫。你將不得不自己編碼。由於YouTube API不支持服務帳戶,因此Chris的建議不起作用。 – DaImTo

+0

所以,你的意思是說,我必須使用HttpClient,對吧? –