-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Status Code: 0 Microsoft.Graph.ServiceException: Code: generalException #1602
Comments
|
This is a Web API project. Sorry, no public repo :( Usual configuration in the startup The method that blows up is: ....... irrelevant code removed...
//this line blows up when using 1.22.0 or 1.22.1
|
Same issue here. In general, whatever that requires an ITokenAcquisition is not working fine. In my case, also downgrading to 1.21.1 fixes the issue. Can´t provide a public repo right now, but could do it soon if required, however, my setup is also quite "standard", following this sample: https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2/tree/master/4-WebApp-your-API/4-3-AnyOrg/ (using .net6 as @JRawlins737, but all works good with 1.21.1) |
Just adding a new finding. builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApi(builder.Configuration, "AzureAd")
.EnableTokenAcquisitionToCallDownstreamApi()
.AddMicrosoftGraph(builder.Configuration.GetSection("MicrosoftGraph"))
.AddDistributedTokenCaches(); It works fine. However, in my scenario, I want to validate the Tenant in the token, so I´m doing: builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApi(options =>
{
builder.Configuration.Bind("AzureAd", options);
options.Events = new JwtBearerEvents
{
OnTokenValidated = async context =>
{
string[] allowedTenants = {
"TENANT1_ID",
"TENANT2_ID"
};
string? tenantId = context.Principal?.Claims.FirstOrDefault(x => x.Type is "tid" or "http://schemas.microsoft.com/identity/claims/tenantid")?.Value;
if (!allowedTenants.Contains(tenantId))
{
throw new Exception("This tenant is not authorized");
}
}
};
}, options => { builder.Configuration.Bind("AzureAd", options); })
.EnableTokenAcquisitionToCallDownstreamApi(options =>
{
builder.Configuration.Bind("AzureAd", options);
})
.AddMicrosoftGraph(builder.Configuration.GetSection("MicrosoftGraph"))
.AddDistributedTokenCaches(); Previous setup fails with 1.22.1, but works with 1.21.1. Note that the setup that works in 1.22.1, the AddMicrosoftIdentityWebApi is returning a MicrosoftIdentityWebApiAuthenticationBuilderWithConfiguration, but the failing setup, the AddMicrosoftIdentityWebApi is returning a MicrosoftIdentityWebApiAuthenticationBuilder |
@JRawlins737 @luismanez : do you want to try the version which is in master currently. We think we fixed it. |
Works for me... :) thanks |
Thanks for confirming, @JRawlins737 ! |
I´m having some issues manually adding the .dlls to my project, so will wait for the release. However, I´ve seen the library is not targeting .NET6. Is there any reason? <TargetFrameworks>netcoreapp3.1; net462; net472; net5.0</TargetFrameworks> Thanks! |
The .NET 5.0 version works perfectly with .NET 6.0, @luismanez |
fixed in 1.22.3 release |
Upgraded Microsoft.Identity.Web from Version 1.21.1. (where is has been working just fine for many weeks) to 1.22.0 then 1.22.1 resulting in the same error. Rolling back to 1.21.1 fixes the issue... Also update TargetFramework from .Net 5 to 6 but still errors out.
Error occurred during the first debug after NuGet updates of Microsoft.Identity.Web and Microsoft.Identity.Web.MicrosoftGraph when the following code was executed in a Web API project.
groupId's is of type
List<String>
and contained 2 GUID's that map to 2 groups.The stack trace of the failure is here:
Expected behavior
The method would normally return a list groups that the current user is a member of..
Actual behavior
Throws exception above..
The text was updated successfully, but these errors were encountered: