小编Tro*_*y G的帖子

使用预先存在的访问令牌通过ASP.NET创建YouTube服务

我一直在一个网站上为用户上传视频到共享的YouTube帐户以供日后访问.经过大量的工作,我已经能够获得一个主动令牌和可行的刷新令牌.

但是,初始化YouTubeService对象的代码如下所示:

UserCredential credential;
using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read))
{
    credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
        GoogleClientSecrets.Load(stream).Secrets, 
        // This OAuth 2.0 access scope allows an application to upload files to the
        // authenticated user's YouTube channel, but doesn't allow other types of access.
        new[] { YouTubeService.Scope.YoutubeUpload },
        "user",
        CancellationToken.None
    );
}

var youtubeService = new YouTubeService(new BaseClientService.Initializer()
{
    HttpClientInitializer = credential,
    ApplicationName = Assembly.GetExecutingAssembly().GetName().Name,
});
Run Code Online (Sandbox Code Playgroud)

我已经有了一个令牌,我想用我的.我正在使用ASP.NET 3.5版,所以async无论如何我都无法打电话.

有没有办法可以在YouTubeService没有async调用的情况下创建一个对象,并使用我自己的令牌?有没有一种方法可以在没有授权代理的情况下构建凭证对象?

或者,该应用程序使用YouTube API V2已有一段时间了,并且有一个带有令牌的表单,并针对与API …

javascript c# asp.net youtube-api google-oauth

19
推荐指数
1
解决办法
751
查看次数

标签 统计

asp.net ×1

c# ×1

google-oauth ×1

javascript ×1

youtube-api ×1