aspnet-contrib / AspNet.Security.OAuth.Providers

OAuth 2.0 social authentication providers for ASP.NET Core
Apache License 2.0
2.38k stars 538 forks source link

Trouble using the BattleNet OAuth client #234

Closed myblindy closed 6 years ago

myblindy commented 6 years ago

This is how I try to initialize it:

            services.AddAuthentication("BattleNet")
                .AddCookie()
                .AddBattleNet(options =>
                {
                    options.ClientId = "***";
                    options.ClientSecret = "***";
                    options.CallbackPath = "/";
                    options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                    options.SaveTokens = true;
                    options.Scope.Add("wow.profile");
                });

            services.AddMvc();
            services.Configure<MvcOptions>(options => options.Filters.Add(new RequireHttpsAttribute()));

And I call app.UseAuthentication(); on the application to enable it.

I put [Authorize] on my controller which triggers the BattleNet login as soon as I open the site, which is exactly what I want, and after I log in it goes into a cycle of loading my / page and then BattleNet again which tells it I'm logged in and tries to open / and again and again until I reach the query string limit.

Is there something I'm missing about this system? I'm not too well versed in MVC Core authentication, but I thought I covered all the bases.

kevinchalet commented 6 years ago

Is there something I'm missing about this system?

Remove options.CallbackPath = "/"; as it's likely what's causing your issue (don't forget it's the intermediate redirect_uri endpoint the user is redirected to by the OAuth2 provider... not the final location he will be ultimately redirected to).