为什么我的本地应用程序没有在iis上运行?

xesrikrc  于 2022-11-12  发布在  其他
关注(0)|答案(1)|浏览(164)

在IIS上,Google身份验证窗口未打开以进行授权。
我正在发布我的原生应用程序并将其移动到服务器。但是,它在服务器(IIS)上不工作。我请求您的帮助。
https://aycokucuz.com/
https://github.com/NortOfKing/TestYok
https://youtu.be/uMAEg4lHc88

fcg9iug3

fcg9iug31#

问题出在你的代码上。从YouTube视频中我可以看到你正在使用GoogleWebAuthorizationBroker。这种授权方法是为已安装的应用程序设计的。它将在运行它的机器上打开Web浏览器窗口,在这种情况下是您的Web服务器。

var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(stream).Secrets,
                                                                             scopes,
                                                                             userName,
                                                                             CancellationToken.None,
                                                                             new FileDataStore(credPath, true)).Result;

您要做的是更改代码以使用Web流,以便在用户客户端上打开同意屏幕。

public void ConfigureServices(IServiceCollection services)
{
    ...

    // This configures Google.Apis.Auth.AspNetCore3 for use in this app.
    services
        .AddAuthentication(o =>
        {
            // This forces challenge results to be handled by Google OpenID Handler, so there's no
            // need to add an AccountController that emits challenges for Login.
            o.DefaultChallengeScheme = GoogleOpenIdConnectDefaults.AuthenticationScheme;
            // This forces forbid results to be handled by Google OpenID Handler, which checks if
            // extra scopes are required and does automatic incremental auth.
            o.DefaultForbidScheme = GoogleOpenIdConnectDefaults.AuthenticationScheme;
            // Default scheme that will handle everything else.
            // Once a user is authenticated, the OAuth2 token info is stored in cookies.
            o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
        })
        .AddCookie()
        .AddGoogleOpenIdConnect(options =>
        {
            options.ClientId = {YOUR_CLIENT_ID};
            options.ClientSecret = {YOUR_CLIENT_SECRET};
        });
}

请在此处查看完整示例。#web-applications-asp.net-core-3

相关问题