Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在使用身份验证代码从提供程序重新提取后,未调用.net OWIN oauth2 AuthenticateCoreAsync()_.net_Oauth_Oauth 2.0_Owin_Owin Middleware - Fatal编程技术网

在使用身份验证代码从提供程序重新提取后,未调用.net OWIN oauth2 AuthenticateCoreAsync()

在使用身份验证代码从提供程序重新提取后,未调用.net OWIN oauth2 AuthenticateCoreAsync(),.net,oauth,oauth-2.0,owin,owin-middleware,.net,Oauth,Oauth 2.0,Owin,Owin Middleware,我正在.net中用OWIN实现oauth。我能够成功登录到我的提供商,并使用url中的身份验证代码重定向到我的应用程序。此时一切似乎都很好,但是AuthenticateCoreAsync()方法似乎没有在我的AuthHandler中使用。这是从URL提取代码以调用令牌端点以获取声明的地方 有人知道为什么这个方法在重定向回我的应用程序时没有被命中吗 根据我的理解,这就是流程: 用户单击登录 应用程序从ApplyResponseCallAngeAsync()重定向到提供程序 提供商重定向到具有授权代

我正在.net中用OWIN实现oauth。我能够成功登录到我的提供商,并使用url中的身份验证代码重定向到我的应用程序。此时一切似乎都很好,但是AuthenticateCoreAsync()方法似乎没有在我的AuthHandler中使用。这是从URL提取代码以调用令牌端点以获取声明的地方

有人知道为什么这个方法在重定向回我的应用程序时没有被命中吗

根据我的理解,这就是流程:

用户单击登录

应用程序从ApplyResponseCallAngeAsync()重定向到提供程序

提供商重定向到具有授权代码的应用程序

我不明白发生了什么

应用程序处于一种状态,其中它具有身份验证代码,但令牌端点尚未命中


我有一个自定义的端点,上面有一个[Authority]标记,点击该标记时,应用程序会提示我登录,然后我完成了登录过程,我回到我的应用程序,验证代码和令牌端点没有被点击。

我刚刚完成了owin OpenIdConnect与Apple ID的集成,我花了很长时间解决了所有问题。 从你的描述中,我认为你没有处理苹果返回的代码。如果是这样,您应该使用自定义openId通知处理程序(AuthorizationCodeReceived)在Startup.Auth.cs中执行此操作,如下所示:

Notifications = new OpenIdConnectAuthenticationNotifications
{
AuthorizationCodeReceived = (context) =>
{
    var clientToken = JwtTokenGenerator.CreateNewToken();

    logger.LogInfo("Apple: clientToken generated");
    context.TokenEndpointRequest.ClientSecret = clientToken;
    logger.LogInfo("Apple: TokenEndpointRequest ready");

    return Task.FromResult(0);
},
TokenResponseReceived = (context) =>
{
    logger.LogInfo("Apple: TokenResponseReceived");

    return Task.FromResult(0);
},
SecurityTokenReceived = (context) =>
{
    logger.LogInfo("Apple: SecurityTokenReceived");

    return Task.FromResult(0);
},
SecurityTokenValidated = (context) =>
{
    string userID = context.AuthenticationTicket.Identity.FindFirst(ClaimTypes.NameIdentifier).Value;
    logger.LogInfo("Apple: SecurityTokenValidated with userID=" + userID);

    return Task.FromResult(0);
},
...
};

app.UseOpenIdConnectAuthentication(appleIdOptions);