[英]How to always request user to login google account when adding a new calendar event in ASP.NET MVC?
I have tried with GoogleWebAuthorizationBroker.AuthorizeAsync()
but it is not working after I hosted in IIS. I have also try to use AppFlowMetadata
but it is not open a new tab to ask for login.我尝试过使用
GoogleWebAuthorizationBroker.AuthorizeAsync()
,但在我托管在 IIS 后它无法正常工作。我也尝试使用AppFlowMetadata
,但它没有打开新选项卡来要求登录。
GoogleWebAuthorizationBroker.AuthorizeAsync() is designed for installed applicaitons. GoogleWebAuthorizationBroker.AuthorizeAsync() 专为已安装的应用程序而设计。 The cosent screen is opened on the machine that the code is running on.
cosent 屏幕在运行代码的机器上打开。 This will work fine when testing but when hosted on IIS its gong to try to open the browser window on your web server.
这在测试时会正常工作,但当托管在 IIS 上时,它会尝试在您的 web 服务器上打开浏览器 window。
You need different code if you want to use it for a web application have a look at Web applications (ASP.NET Core 3) .如果要将它用于 web 应用程序,则需要不同的代码,请查看Web 应用程序 (ASP.NET Core 3) 。
[GoogleScopedAuthorize(CalendarService.ScopeConstants.Calendar)]
public async Task<IActionResult> CalendarEventsList([FromServices] IGoogleAuthProvider auth)
{
GoogleCredential cred = await auth.GetCredentialAsync();
var service = new CalendarService(new BaseClientService.Initializer
{
HttpClientInitializer = cred
});
var request = var request = service.Events.List("primary");
return View(request.Execute());
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.