2016-04-04 22 views
5

Tôi gặp sự cố với Youtube Api v3. Vấn đề là muốn lấy thông tin từ một video tải lên, khi thực hiện truy xuất thông tin cho video, tôi nhận được lỗi 403 Cấm.Lỗi 403 Forbidden whith Youtube API V3

Nếu tôi chạy url tôi đang sử dụng trình duyệt sẽ trả về Json cho tôi với tất cả dữ liệu video.

Visual Studio Lỗi

screenshot 1

Cùng Url trong trình duyệt.

screenshot 2

if (videoId != "") 
      { 

       // If the video has the same description as a video and uploaded to YouTube, then I have removed that was uploaded earlier and upload the newrequest.Service.QueryClientLoginToken(); 
       //Uri urlVideo = new Uri(String.Format("http://gdata.youtube.com/feeds/api/users/{0}/uploads/{1}", hipoConfig.canal_youtube, videoId)); This is This is the URL of the version 2.0 
       Uri urlVideo = new Uri(String.Format("https://www.googleapis.com/youtube/v3/videos?id={0}&key={1}&part=snippet", videoId, hipoConfig.clave_api)); 

       Video ExistingVideo = request.Retrieve<Video>(urlVideo); 
       log.escribirInfoLog("Informacion: El video " + ExistingVideo.VideoId + "se elimina de YouTube para ser sustituido"); 

       request.Delete(ExistingVideo); 

Trả lời

1

Các bạn đã thử thêm OAuth cho phép yêu cầu của bạn? Sau khi kiểm tra mô tả mã lỗi trong YouTube Data API - Errors:

cấm (403)

Truy cập bị cấm. Yêu cầu có thể không được ủy quyền đúng cách.

Bạn có thể thử thêm OAuth bằng tài liệu này trên YouTube Data API Overview làm hướng dẫn.

Nếu ứng dụng của bạn sẽ sử dụng bất kỳ phương pháp API mà đòi hỏi người sử dụng ủy quyền, đọc hướng dẫn xác thực để học hỏi làm thế nào để thực hiện quyền của OAuth 2.0.

Các vấn đề liên quan