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

Azure US Gov, Delegated auth, null ref exception. #39

Open
drdenson opened this issue Apr 4, 2023 · 0 comments
Open

Azure US Gov, Delegated auth, null ref exception. #39

drdenson opened this issue Apr 4, 2023 · 0 comments

Comments

@drdenson
Copy link

drdenson commented Apr 4, 2023

Hi, testing delegated authentication with a GCCH/DOD account is failing with a null ref exception when creating the service obj. Debug shows the failure in the oAuthHelper class - seems as tho MSAL doesn't like the PCA object created with the default/global authority and trying to use that for non-global auth flows. I worked up a quick switch statement to take the authority string and map that to the enum used in the PCA options object so that we create the PCA object with the correct authority from the beginning.

oAuthHelper.cs (inject @ LINE 92):

        //Initialize the cloudInstance enum.
        var OAuth2AzCloudInstance = AzureCloudInstance.None;

        //Switch to set logon authority enum.
        switch (OAuth2Authority)
        {
            case "https://login.microsoftonline.us":
                OAuth2AzCloudInstance = AzureCloudInstance.AzureUsGovernment;
                break;

            case "https://login.microsoftonline.de":
                OAuth2AzCloudInstance = AzureCloudInstance.AzureGermany;
                break;

            case "https://login.partner.microsoftonline.cn":
                OAuth2AzCloudInstance = AzureCloudInstance.AzureChina;
                break;
            default:
                OAuth2AzCloudInstance = AzureCloudInstance.AzurePublic;
                break;
        }

        if (OAuth2RedirectUrl != "<Do not use a redirect URL.>")
        {
            // Configure the MSAL client to get tokens
            pcaOptions = new PublicClientApplicationOptions
            {
                ClientId = ClientId,
                TenantId = TenantId,
                RedirectUri = OAuth2RedirectUrl,
                AzureCloudInstance = OAuth2AzCloudInstance
            };
dseph added a commit that referenced this issue Apr 4, 2023
…exception. #39

Trying some code to add a calendar check window - issues with integration and my pull later.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant