I'm using the AuthenticationBuilder.AddOAuth(...) method to add OAuth functionality to my site. This is working perfectly for one service I am connecting to, but the same doesn't go for the second service.
Apparently, during the redirect to the authorization endpoint, the second service requires the URL parameter return_type to be set to token, my configuration sets it to code though. I haven't been able to find what part of the OAuthOptions determines this parameter so far.
I'll add the code I am using for convenience:
authBuilder.AddOAuth(Identifier, options =>
{
options.ClientId = ClientId;
options.ClientSecret = ClientSecret;
options.CallbackPath = new PathString($"/signin-{Identifier}");
options.AccessDeniedPath = new PathString("/");
options.AuthorizationEndpoint = Domain + AuthorizationEndpoint;
options.TokenEndpoint = Domain + TokenEndpoint;
options.UserInformationEndpoint = Domain + UserInfoEndpoint;
options.ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, NameIdentifierKey);
options.ClaimActions.MapJsonKey(ClaimTypes.Name, NameKey);
options.SaveTokens = true;
options.Events = new OAuthEvents
{
OnCreatingTicket = async context =>
{
var request = new HttpRequestMessage(HttpMethod.Get, context.Options.UserInformationEndpoint);
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", context.AccessToken);
var response = await context.Backchannel.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, context.HttpContext.RequestAborted);
response.EnsureSuccessStatusCode();
var user = await JsonDocument.ParseAsync(await response.Content.ReadAsStreamAsync());
context.RunClaimActions(user.RootElement);
}
};
options.Scope.Add(Scope);
});