C# 使用youtube API V3 for C时出错#

C# 使用youtube API V3 for C时出错#,c#,youtube-api,google-api,youtube.net-api,C#,Youtube Api,Google Api,Youtube.net Api,我在我的应用程序中使用了youtube API V3。我引用它来检索与关键字关联的搜索结果 public static void Search(string keyword, ref List<string> videoList) { // Validate keyword if (string.IsNullOrWhiteSpace(keyword)) { return; }

我在我的应用程序中使用了youtube API V3。我引用它来检索与关键字关联的搜索结果

    public static void Search(string keyword, ref List<string> videoList)
    {
        // Validate keyword
        if (string.IsNullOrWhiteSpace(keyword))
        {
            return;
        }
        // Create a youtube service
        YoutubeService youtube = new YoutubeService(new BaseClientService.Initializer()
        {
            ApiKey = GoogleCredentials.apiKey
        });

        SearchResource.ListRequest listRequest = youtube.Search.List("snippet");
        listRequest.Q = keyword;
        listRequest.Order = SearchResource.Order.Rating;

        // Fetch the response from youtube
        SearchListResponse searchResponse = listRequest.Fetch();


        foreach (SearchResult searchResult in searchResponse.Items)
        {
            videoList.Add(searchResult.Id.VideoId);
        }
    }
它抛出以下错误

Google.API.dll中发生类型为“Google.GoogleAppRequestException”的未处理异常 其他信息:Google.api.Requests.RequestError


有什么问题吗?

我犯了一个愚蠢的错误。我没有使用API密钥,而是使用了客户端密码。更换后,错误得到解决

        SearchListResponse searchResponse = listRequest.Fetch();
  Bad Request [400]