使用 Youtube v3 Api 密钥 [英] Using Youtube v3 Api key

查看:116
本文介绍了使用 Youtube v3 Api 密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个基于 youtube 的应用程序,我使用的是 3.0 版的 Youtube Data API,我确实在 Google Cloud Console 中注册了该应用程序,并且确实获得了一个 API 密钥.之后,我尝试在 Visual Studio 2010 的控制台应用程序中对其进行测试,我使用 WebClient 来检索使用此 URL 的视频搜索"https:///www.googleapis.com/youtube/v3/search?part=snippet&q=YouTube+Data+API&type=video&key={MY API KEY}"

I'm trying to build an youtube based app, and I'm using version 3.0 of Youtube Data API, I did register the app in Google Cloud Console and I did obtain an API Key. After that I tried to test it in a console application in Visual Studio 2010, I used a WebClient to retrieve a video search using this URL "https://www.googleapis.com/youtube/v3/search?part=snippet&q=YouTube+Data+API&type=video&key={MY API KEY}"

我从此处了解到这一点.我同时使用了浏览器密钥和服务器密钥,但服务器发回一个错误,指出请求不正确.

I learned this from here. I used both a Browser key and a Server key, but the server sends back an error saying the request is incorrect.

那么谁能指出我犯的错误?

So can anyone point me to the error I'm making?

PS:我正在尝试制作 Windows Phone 应用程序,在此之前我想先学习如何操作 Youtube API,这就是我在控制台应用程序中进行测试的原因

PS: I am trying to make a windows phone app, and before doing so I wanted to learn how to manipulate the Youtube API first, this is why I am testing in a console application

推荐答案

确保在 Google 开发者控制台.它应该看起来像这样:

Make sure that the YouTube Data API is enabled in the Google Developer Console. It should look something like this:

您要查找的密钥是服务器密钥,如下所示:

The key you are looking for is the server key, which looks something like this:

(为了安全起见,我已经截断了我的密钥).我现在将其复制并粘贴到我的浏览器窗口中:

(I've truncated my key for security purposes). I now copy and paste this into my browser window:

https://www.googleapis.com/youtube/v3/search?part=snippet&q=YouTube+Data+API&type=video&key=YOURKEYWOULDGOHERE

这对我有用.从这里开始验证密钥是否有效以及 API 是否已正确启用.我建议使用 API 客户端,因为某些 API 调用将需要 OAuth 2.0 访问令牌,而不是简单的 API 密钥(搜索 API 需要常规的简单 API 密钥).

This works for me. Start here to verify that the key is working and that the API has been enabled correctly. I suggest using the API client, because some API calls will require an OAuth 2.0 access token, not the simple API key (search API requires regular simple API key).

这篇关于使用 Youtube v3 Api 密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆