I am using Azure Active Directory and to get the correct token response I need to change the current "response_type" from "token" to "id_token", how can I achieve this?
Can you show what the current spec is and the expected one?
Does this help: https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-implicit-grant-flow#send-the-sign-in-request
The table with the parameters expected in the request is a little further down.
How did you configure the spec?
Where do you need this? In swagger ui?
Yes I was hoping to have this in available for Swagger UI, it looks like they expose an x-tokenName property that I think acomplishes it. Sorry if I am not clear I am not super well versed in this
For completeness
services
.AddOpenApiDocument((options, serviceProvider) =>
{
options.AddSecurity("bearer", new string[0], new OpenApiSecurityScheme
{
Type = OpenApiSecuritySchemeType.OAuth2,
Description = "Bearer authentication using Azure Active Directory",
Flow = OpenApiOAuth2Flow.Implicit,
AuthorizationUrl = $"{Configuration["Authentication:BaseUrl"]}/oauth2/v2.0/authorize?nonce=SWAGGER",
Scopes = new Dictionary<string, string>
{
[$"{Configuration["Authentication:ClientId"] ?? "CLIENT_ID"}/.default"] = "The resource we are accessing"
}
});
options.OperationProcessors.Add(new AspNetCoreOperationSecurityScopeProcessor("JWT token"));
});
app
.UseSwaggerUi3(settings =>
{
settings.OAuth2Client = new OAuth2ClientSettings
{
ClientId = Configuration["Authentication:ClientId"],
};
});
/swagger/v1/swagger.json"securitySchemes": {
"bearer": {
"type": "oauth2",
"description": "Bearer authentication using Azure Active Directory",
"flows": {
"implicit": {
"authorizationUrl": "**snip**/oauth2/v2.0/authorize?nonce=SWAGGER",
"scopes": {
"**snip**/.default": "The resource we are accessing"
}
}
}
}
}
So you'd do this:
```
options.AddSecurity("bearer", new string[0], new OpenApiSecurityScheme
{
Type = OpenApiSecuritySchemeType.OAuth2,
ExtensionData = { { "x-tokenName", "id_token" } },
...
With that I can see it has been added to the swagger definition, yay! Now its just down to swagger ui to use that for OpenAPI3 documents.
Thank you so much for your help
Is it supported now? I am having similar issues. Because swagger ui always uses token response type
@hypervtechnics The answer above works but the syntax changed a bit:
ExtensionData = new Dictionary<string, object>
{
{ "x-tokenName", "access_token" }
}