相关疑难解决方法(0)

我得到"此请求已被拒绝授权." 使用OWIN oAuth中间件(具有单独的Auth和资源服务器)时出现错误消息

我试图解耦我的身份验证和资源服务器.我按照本教程中提供的示例进行操作:

http://bitoftech.net/2014/09/24/decouple-owin-authorization-server-resource-server-oauth-2-0-web-api/

这是我的auth服务器中的Startup.cs中的代码:

using Microsoft.Owin;
using Microsoft.Owin.Security.OAuth;
using Owin;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace AuthServer.Web
{
   public class Startup
   {
      public void Configuration(IAppBuilder app) {
         ConfigureOAuth(app);
      }

      public void ConfigureOAuth(IAppBuilder app)
      {
         OAuthAuthorizationServerOptions OAuthServerOptions = new OAuthAuthorizationServerOptions()
         {
            AllowInsecureHttp = true,
            TokenEndpointPath = new PathString("/token"),
            AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),
            Provider = new SimpleAuthorizationServerProvider()
         };

         // Token Generation
         app.UseOAuthAuthorizationServer(OAuthServerOptions);
         app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());

      }
   }
}
Run Code Online (Sandbox Code Playgroud)

这是我的资源服务器中的startup.cs(即我的示例Web api应用程序):

using Microsoft.Owin.Security.OAuth;
using Owin;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web; …
Run Code Online (Sandbox Code Playgroud)

asp.net oauth oauth-2.0 asp.net-web-api owin

23
推荐指数
3
解决办法
6万
查看次数

标签 统计

asp.net ×1

asp.net-web-api ×1

oauth ×1

oauth-2.0 ×1

owin ×1