Goal: 我想使用OpenID Connect保护我的Web服务(使用OWIN的ASP.NET Web API) . 身份提供商是Google .

Important: 我只负责网络服务 . 我没有任何Web应用程序(没有UI;这取决于使用我的Web服务的第三方) .

Considerations: 由于我的Web服务在服务器上运行,我认为最好使用授权代码流(或混合?) .

What's done so far :我配置了OWIN(在我的Web服务中)以使用OpenID Connect( UseOpenIdConnectAuthentication ) .

Current behavior: 我有人未经授权尝试访问网络服务,网络服务将她(发送302)重定向到Google . 因为我没有_317358_直到第三方正确显示同意页面 . 假设用户同意并按"Accept" .

在这里,我被卡住......据我所知,谷歌发回授权码(我的网络服务可以使用它来获取访问令牌) . 我怎样才能获得授权码? Google是否支持授权代码流程( ResponseType = code )?

app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
    ClientId = "aClientId",
    ClientSecret = "aClientSecret",
    Authority = "https://accounts.google.com/",
    RedirectUri = "do I need this??",  //I guess here I would register a resources... but what to do in there?
    ResponseType =  "code",            //does Google even support code??
    Scope = "openid",                
    Notifications = new OpenIdConnectAuthenticationNotifications()
    {
        AuthorizationCodeReceived = (context) =>
        {
            var code = context.Code; //I never got to this point so far
            //do stuff
            return Task.FromResult(0);
        }
    },
});

我是否必须手动调用Google(以获取访问令牌),然后使用 GetOwinContext().Authentication.SignIn(id); 进行SignIn或OWIN中间件处理此问题?

更新:一个repro在这里:https://github.com/Dunken/WebApiOpenIdConnect