我正在使用此代码在 youtube 上上传视频
代码在我的本地机器上运行良好,但是当我在我的 IIS 上托管我的 api 时出现异常
这是我得到的异常
Object reference not set to an instance of an object. System.Collections.ListDictionaryInternal at BusinessClass.UploadVideo.videosInsertRequest_ProgressChanged(IUploadProgress progress) at Google.Apis.Upload.ResumableUpload
1.<UploadAsync>d__84.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter
1.GetResult() at BusinessClass.UploadVideo.d__1.MoveNext() Object reference not set to an instance of an object. Void videosInsertRequest_ProgressChanged(Google.Apis.Upload.IUploadProgress)
使用 client_secrets.json 文件进行授权。
最佳答案
解决了这个问题,我得到了未授权异常,因为在这个文件夹中
C:\Users\Administrator\AppData\Roaming\Google.Apis.Auth\Google.Apis.Auth.OAuth2.Responses.TokenResponse-user
IIS 用户没有访问权限,因此我将此“Google.Apis.Auth”文件夹的权限授予 IIS 用户。最后异常消失了,代码运行正常,感谢您的帮助
关于c# - YouTube 数据 API (v3) 在 Windows 服务器 (IIS) 中托管,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41801398/