【问题标题】:youtube api with asp.net (401) Unauthorized error带有 asp.net 的 youtube api (401) 未经授权的错误
【发布时间】:2013-02-12 21:02:40
【问题描述】:

每次我尝试使用 youtube api 时都会收到此错误:

远程服务器返回错误:(401) Unauthorized.

关于此代码:

public static YouTubeRequest AuthRequest()
    {
        YouTubeRequestSettings Setting =
            new YouTubeRequestSettings("app", "key", "email", "pass");
        Setting.Timeout = 99999999;
        YouTubeRequest _request = new YouTubeRequest(Setting);
        return _request;
    }

我在这里获得了密钥:http://code.google.com/apis/youtube/dashboard

电子邮件和密码,我检查了几次,它们工作正常。

我也在这里注册了我的申请:https://code.google.com/apis/console

但是每次我尝试使用请求时都会收到错误,这是什么问题? 谢谢

【问题讨论】:

    标签: asp.net youtube-api unauthorized


    【解决方案1】:

    我不能离开cmets,你也没有提到这个,但是你有没有在YouTubeRequestSettings构造函数方法中将“app”替换为你的应用程序的名称?将代码保留为“app”会阻止访问。

    编辑:我查看了 YouTube API 的 .NET page,但找不到您正在使用的构造函数。他们列出的唯一构造函数是:

    • YouTubeRequestSettings("example app", clientID, developerKey)
    • YouTubeRequestSettings("example app", clientID, developerKey, (String) SessionToken)
    • YouTubeRequestSettings("example app", clientID, developerKey, username, password)
    • YouTubeRequestSettings("NETUnittests", this.ytClient, this.ytDevKey, this.ytUser, this.ytPwd)

    【讨论】:

    • 看看我对答案所做的补充是否有帮助
    • 您是否可以参考我第一次添加 API 时链接到的 API 页面?
    • 我还在 SO 上发现了一个类似的问题,可能会有所帮助stackoverflow.com/questions/10759032
    • 不幸的是,这些建议都没有解决问题。至于构造函数,我已经使用了一段时间(其他应用程序),它工作正常。谢谢
    • 我忘了说使用开发帐户一切正常。
    猜你喜欢
    • 2017-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-01
    • 2016-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多