Using Youtube v3 Api key

2019-05-29 22:48发布

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: 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

1条回答
三岁会撩人
2楼-- · 2019-05-29 23:25

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

enter image description here

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

enter image description here

(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

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).

查看更多
登录 后发表回答