-
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
Error GetAccessTokenForAppAsync Exception thrown: 'System.NullReferenceException' in System.Private.CoreLib.dll #2410
Comments
it might be a duplicate of #2394 |
thanks @emmanuelpare I see that you wrote
I would recommend you use:
instead of the following: .AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(configuration.GetSection("AzureAd"))
.EnableTokenAcquisitionToCallDownstreamApi() I think this should fix your issue. _ Aside, I think we've introduced a bug in 2.13.3, indeed, (by not using the ASP.NET Core token TokenAcquisition, but the default token acquisition): I had not anticipated that you could use AddMicrosoftWebApp without really needing a web app :-). |
Here the stacktrace |
Hi Thanks jmprieur I will try to implement your advice.... Iam building a console application that need to use a protected webapi. Iam using the webapp to be able to use dependancy injection into my console app. |
If you need a console app calling a protected web API, you might want to try out this sample, @emmanuelpare |
@emmanuelpare any update on this? Going to close, but please re-open if it's still not working. |
Microsoft.Identity.Web Library
Microsoft.Identity.Web
Microsoft.Identity.Web version
2.13.3
Web app
Sign-in application and call web APIs
Web API
Protected web APIs call downstream web APIs
Token cache serialization
In-memory caches
Description
Iam building a console app in dotnet core that consume a protected webapi. Since I upgraded to 2.13.3 tokenresult thrown an exception "Exception thrown: 'System.NullReferenceException' in System.Private.CoreLib.dll" Object reference not set to an instance of an object.
Reproduction steps
Here is how Iam starting the console app with dependancy injection. I think it might be the cause of my issue but I dont know enough to explain why.
Error message
{"Object reference not set to an instance of an object."}
Id Web logs
No response
Relevant code snippets
Regression
2.13.2
Expected behavior
It should return the token
The text was updated successfully, but these errors were encountered: