APIを介してYouTubeにアップロードしようとしていますが、ローカルで実行している間は正常に動作します。Azure アプリにあると、(403) Forbidden が表示されます
これが私のコードです:
YouTubeRequestSettings settings = new YouTubeRequestSettings("XXXXX", token, userName, Password);
YouTubeRequest request = new YouTubeRequest(settings);
Video newVideo = new Video();
newVideo.Title = "Test";
newVideo.Tags.Add(new MediaCategory("Autos", YouTubeNameTable.CategorySchema));
newVideo.Keywords = "car";
newVideo.Description = "My first try";
newVideo.YouTubeEntry.Private = false;
newVideo.Tags.Add(new MediaCategory("devTag",
YouTubeNameTable.DeveloperTagSchema));
newVideo.YouTubeEntry.MediaSource = new MediaFileSource(**SaveFileToLocal**(fileUpload), fileUpload.ContentType);
Video createdVideo = request.Upload(newVideo);
private string **SaveFileToLocal**(HttpPostedFileBase fileUpload)
{
string uploadedFilePath;
if (Local)
{
var uploadPath = Server.MapPath("~/AlbumsUploads//" + "RD");
uploadedFilePath = Path.Combine(uploadPath, fileUpload.FileName);
}
else
{
LocalResource localResource = RoleEnvironment.GetLocalResource("LocalWebRoleStorage");
string[] paths = { localResource.RootPath, DateTime.Now.Ticks.ToString() + "_temp" + fileUpload.FileName.Substring(fileUpload.FileName.LastIndexOf('.')) };
uploadedFilePath = Path.Combine(paths);
}
using (var fs = new FileStream(uploadedFilePath, FileMode.Create))
{
var buffer = new byte[fileUpload.InputStream.Length];
fileUpload.InputStream.Read(buffer, 0, buffer.Length);
fs.Write(buffer, 0, buffer.Length);
}
return uploadedFilePath;
}
そして、ここに私の例外があります。
Google.GData.Client.GDataRequestException: Execution of request failed: https://uploads.gdata.youtube.com/feeds/api/users/default/uploads ---> System.Net.WebException: The remote server returned an error: (403) Forbidden.
at System.Net.HttpWebRequest.GetResponse()
at Google.GData.Client.GDataRequest.Execute()
--- End of inner exception stack trace ---
at Google.GData.Client.GDataRequest.Execute()
at Google.GData.Client.GDataGAuthRequest.Execute(Int32 retryCounter)
at Google.GData.Client.MediaService.EntrySend(Uri feedUri, AtomBase baseEntry, GDataRequestType type, AsyncSendData data)
at Google.GData.Client.Service.Insert(Uri feedUri, AtomEntry newEntry, AsyncSendData data)
at Google.YouTube.YouTubeRequest.Upload(String userName, Video v)
at MvcWedApp.Controllers.AlbumManagementController.UploadToYouTube(HttpPostedFileBase fileUpload, Int32 albumId)
at MvcWedApp.Controllers.AlbumManagementController.Upload(Nullable`1 chunk, String name)
誰でも助けてくれますか?