i am calling youtube api to get list of youtube video data. but i am getting get 403 error. i also enabled YouTube Data API (v3).
I am trying to get a list of videos from YouTube using YouTube API. I am using an API key. When I use the URL below everything works fine and I get the desired results: GET https://www.googleapis.com/youtube/v3/videos?id=i7KKDpmnR7U&key=YOUR_API_KEY=snippet,statistics,contentDetails
but when i tried locally i am unable to print the success response in my console. i always getting error response as get 403 forbidden. Is there is any issue when we run in local environment? or there is any issues with the Api
something missing any hints would be Great!
$scope.youtubeApi = function(videoId){
console.log('youtubeApi: ' + JSON.stringify(videoId));
if (videoId) {
//console.log('Youtube API Call function is called and Video is is : ' + videoId);
var API_KEY = "AIzaSyCmsmxLnAnDxwQ6wzzzHnLEGBt7X8ce94wI10A";
$http.get("https://www.googleapis.com/youtube/v3/videos?id="+ videoId + "&key=" + API_KEY + "&part=snippet,statistics,contentDetails").
success(function (data, status, headers, config) {
console.log('sucess call.' + JSON.stringify(data));
//$timeout(parseresults(data), 500);
//formObject(data);
}).
error(function (data, status, headers, config) {
console.log('Error while saving this Video Id details in rest.' + JSON.stringify(data));
console.log('Error while saving this Video Id details in rest.' + videoId);
});
}
}
{
"error": {
"errors": [
{
"domain": "global",
"reason": "forbidden",
"message": "Forbidden"
}
],
"code": 403,
"message": "Forbidden"
}
}
i am getting error only when i tried to run locally using $http.get() method. but when i manually tying the url with apikey and videoId on browser window(https://www.googleapis.com/youtube/v3/videos?id=i7KKDpmnR7U&key=AIzaSyBbyrB-WGvDSYrxHhEnQfcTuiyrDkF7LwI&part=snippet,statistics,contentDetails), got success response in browser ie video object.
As per the YouTube v3 error document. Error type 403 is a symbol of either forbidden
or quotaExceeded
. Please find below the description.
Hence, The channel specified by the id (i7KKDpmnR7U)
parameter does not support the request or the request is not properly authorized.
OR
The videos.list
method returns a forbidden (403) error when an improperly authorized request tries to retrieve the details of a video resource. Those parts are only available to the video's owner.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With