dotnet / dotnet/aspnetcore

Updating to .NET 8 Preview 1 breaks AuthorizationEndpoint query on AddGoogle

Open
#47,054 18 comments 1 reaction 0 assignees View on GitHub
area-auth bug
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

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](https://learn.microsoft.com/en-us/dotnet/core/compatibility/8.0) 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**
```xml


net8.0
enable



```

**Program.cs**
```c#
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** : https://github.com/dotnet/aspnetcore/issues/47054#issuecomment-1786192809

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.