代码之家  ›  专栏  ›  技术社区  ›  Max Boy

找不到ApplicationAuthProvider

  •  1
  • Max Boy  · 技术社区  · 6 年前

    有人知道我应该安装哪个软件包来修复此问题吗?我已经安装了Microsoft。AspNet。WebApi。奥温

    我得到:在我的CorsApi中找不到类型或命名空间“ApplicationAuthProvider”

        namespace CorsApi
    {
        public partial class Startup
        {
            static Startup()
            {
                PublicClientId = "self";
    
                UserManagerFactory = () => new UserManager<IdentityUser>(new UserStore<IdentityUser>());
    
                OAuthOptions = new OAuthAuthorizationServerOptions
                {
                    TokenEndpointPath = new PathString("/Token"),
                    Provider = new ApplicationOAuthProvider(PublicClientId, UserManagerFactory),
                    AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
                    AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
                    AllowInsecureHttp = true
                };
            }
    
            public static OAuthAuthorizationServerOptions OAuthOptions { get; private set; }
    
            public static Func<UserManager<IdentityUser>> UserManagerFactory { get; set; }
    
            public static string PublicClientId { get; private set; }
    
            // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
            public void ConfigureAuth(IAppBuilder app)
            {
                // Enable the application to use a cookie to store information for the signed in user
                // and to use a cookie to temporarily store information about a user logging in with a third party login provider
                app.UseCookieAuthentication(new CookieAuthenticationOptions());
                app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
    
                // Enable the application to use bearer tokens to authenticate users
                app.UseOAuthBearerTokens(OAuthOptions);
    
                // Enable CORS
                app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
    
                // Uncomment the following lines to enable logging in with third party login providers
                //app.UseMicrosoftAccountAuthentication(
                //    clientId: "",
                //    clientSecret: "");
    
                //app.UseTwitterAuthentication(
                //    consumerKey: "",
                //    consumerSecret: "");
    
                //app.UseFacebookAuthentication(
                //    appId: "",
                //    appSecret: "");
    
                //app.UseGoogleAuthentication();
            }
        }
    }
    

    我试图安装corsAPI,但我开始遇到这个问题。

    谢谢

    1 回复  |  直到 4 年前
        1
  •  1
  •   karique    5 年前

    如果有人遇到同样的问题,他们会将类的名称从“ApplicationAuthProvider”更改为“OAuthAppProvider”。只需使用“OAuthAppProvider”: