-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Currently writing an OAuthHandler. The OAuthCreatingTicketContext still requires a JObject as per below screenshot.
Yet, when I look at the source code, it is clear that JObject
has been replaced by JsonElement
.
Also when I look at the file's history, I can see that the change took place on the 5th of Feb. 2019 as per change #7105.
And an announcement has been made for it as well.
https://github.com/dotnet/aspnetcore/issues/7289
Expected Behavior
I then expected to be able to pass on a JsonElement
as per examples for Google Authentication and the others.
` ///
protected override async Task CreateTicketAsync(
ClaimsIdentity identity,
AuthenticationProperties properties,
OAuthTokenResponse tokens) {
// Get the Google user
var request = new HttpRequestMessage(HttpMethod.Get, Options.UserInformationEndpoint);
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", tokens.AccessToken);
var response = await Backchannel.SendAsync(request, Context.RequestAborted);
if (!response.IsSuccessStatusCode)
{
throw new HttpRequestException($"An error occurred when retrieving Google user information ({response.StatusCode}). Please check if the authentication information is correct.");
}
using (var payload = JsonDocument.Parse(await response.Content.ReadAsStringAsync(Context.RequestAborted)))
{
// Here, the payload.RootElement is a JsonElement.
var context = new OAuthCreatingTicketContext(new ClaimsPrincipal(identity), properties, Context, Scheme, Options, Backchannel, tokens, payload.RootElement);
context.RunClaimActions();
await Events.CreatingTicket(context);
return new AuthenticationTicket(context.Principal!, context.Properties, Scheme.Name);
}
}`
Steps To Reproduce
- Create new .Net 6 Project
- Install package Microsoft.AspNetCore.Authentication.OAuth
- Replicate code from Google Authentication
- Then you should see a red underline for payload.RootElement
Exceptions (if any)
.NET Version
7.0.100-preview.6.22352.1
Anything else?
.Net 6 Project
VS 2022 v17.2.6
Nuget Package Manager v6.2.1
I noticed that the package Microsoft.AspNetCore.Authentication.OAuth was built from an archived source at
https://github.com/aspnet/Security/tree/93926543f8469614c2feb23de8a8c0561b8b2463
Rather than current source like the other authentication providers.