Description
The following web application correctly shows a Google sign in page when it is built with net7.0
and version 7.0.3
of Microsoft.AspNetCore.Authentication.Google
. Note that a prompt
query parameter is added to the authorization endpoint to force an account selection dialog to appear, rather than automatically signing in with the current Google account.
In net8.0
(Preview 1), the same app shows an error page on accounts.google.com:
Access blocked: authorisation error
OAuth 2 parameters can only have a single value: prompt
Error 400: invalid_request
This is a breaking change, but I couldn't find it on the Breaking Changes in .NET 8 page. It might be enough of an edge case that it doesn't matter, but I thought I'd raise an issue just in case.
WebApplication1.csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="8.0.0-preview.1.23112.2" />
</ItemGroup>
</Project>
Program.cs
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.Google;
var builder = WebApplication.CreateBuilder(args);
builder.Services
.AddAuthentication(o => {
o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
o.DefaultChallengeScheme = GoogleDefaults.AuthenticationScheme;
})
.AddCookie()
.AddGoogle(o =>
{
o.ClientId = builder.Configuration["Google:ClientId"];
o.ClientSecret = builder.Configuration["Google:ClientSecret"];
o.AuthorizationEndpoint += "?prompt=select_account"; // <-- Broken in .NET 8
});
var app = builder.Build();
app.UseAuthentication();
app.MapGet("/", () => Results.Challenge());
app.Run();
dotnet --version
8.0.100-preview.1.23115.2
Summary Comment : #47054 (comment)