Skip to content
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

MISE - OwinTokenAcquirerFactory Null exception during startup #3181

Closed
jmprieur opened this issue Jan 7, 2025 · 1 comment
Closed

MISE - OwinTokenAcquirerFactory Null exception during startup #3181

jmprieur opened this issue Jan 7, 2025 · 1 comment
Assignees
Labels
1P bug Something isn't working P1
Milestone

Comments

@jmprieur
Copy link
Collaborator

jmprieur commented Jan 7, 2025

Microsoft.Identity.Web Library

Microsoft.Identity.Web

Microsoft.Identity.Web version

Latest

Web app

Not Applicable

Web API

Protected web APIs call downstream web APIs

Token cache serialization

In-memory caches

Description

application is currently running on .NetFramework 4.7.2 and using Microsoft.Identity.Web.OWIN package,

The application is getting Null exception at line
OwinTokenAcquirerFactory tokenAcquirerFactory = TokenAcquirerFactory.GetDefaultInstance();

on investigating, it the source code for OwinTokenAcquirerFactory

          ["AzureAd:Instance"] = EnsureTrailingSlash(ConfigurationManager.AppSettings["ida:Instance"] ?? ConfigurationManager.AppSettings["ida:AADInstance"] ?? "https://login.microsoftonline.com/"),
                ["AzureAd:ClientId"] = ConfigurationManager.AppSettings["ida:ClientId"],
                ["AzureAd:TenantId"] = ConfigurationManager.AppSettings["ida:Tenant"] ?? ConfigurationManager.AppSettings["ida:TenantId"],
                ["AzureAd:Audience"] = ConfigurationManager.AppSettings["ida:Audience"],
                ["AzureAd:ClientSecret"] = ConfigurationManager.AppSettings["ida:ClientSecret"],
                ["AzureAd:SignedOutCallbackPath"] = ConfigurationManager.AppSettings["ida:PostLogoutRedirectUri"],
                ["AzureAd:RedirectUri"] = ConfigurationManager.AppSettings["ida:RedirectUri"],
            });
            return HttpContext.Current.Request.PhysicalApplicationPath;
        }

HttpContext.Current.Request.PhysicalApplicationPath throwing the null exception as the code executed during the startup of application, there will be no HttpContext.Current.Request

Reproduction steps

See above

Error message

NRE

Id Web logs

NRE

Relevant code snippets

See above

Regression

No regression

Expected behavior

no NRE

@jmprieur
Copy link
Collaborator Author

jmprieur commented Jan 7, 2025

We could use:

PhysicalApplicationPath = HostingEnvironment.MapPath("~/");

which would work even when there is no request

@jmprieur jmprieur mentioned this issue Jan 7, 2025
@jennyf19 jennyf19 added this to the 3.5.1 milestone Jan 7, 2025
@jmprieur jmprieur closed this as completed Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1P bug Something isn't working P1
Projects
None yet
Development

No branches or pull requests

2 participants