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

fix(msalprovider): Fix error when providing TenantId #178

Merged
merged 2 commits into from
Dec 10, 2021

Conversation

brekkjen
Copy link
Contributor

@brekkjen brekkjen commented Dec 4, 2021

Fixes #170

https://github.com//issues/170

PR Type

What kind of change does this PR introduce?

  • Bugfix

What is the current behavior?

Providing TenantId causes both WithTenantId and WithAuthority to be specified and those are mutually exclusive resulting in error

What is the new behavior?

Providing TenantId excludes WithAuthority

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
  • Sample in sample app has been added / updated (for bug fixes / features)
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes

Other information

Providing TenantId resulted in both WithTenantId and WithAuthority to be specified wich are mutually exclusive resulting in error
@ghost
Copy link

ghost commented Dec 4, 2021

Thanks brekkjen for opening a Pull Request! The reviewers will test the PR and highlight if there is any merge conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌

@net-foundation-cla
Copy link

net-foundation-cla bot commented Dec 4, 2021

CLA assistant check
All CLA requirements met.

@shweaver-MSFT
Copy link
Member

Thanks for submitting, and sorry it took me a few days to get to it. I've got one nitpick, now that the authority is only required if the tenantId is null, we should move the authority declaration into the else statement closest to where it's being used.

if (tenantId != null)
{
    clientBuilder = clientBuilder.WithTenantId(tenantId);
}
else
{
    // If the TenantId is not provided, use WithAuthority
    var authority = listWindowsWorkAndSchoolAccounts ? AadAuthorityAudience.AzureAdAndPersonalMicrosoftAccount : AadAuthorityAudience.PersonalMicrosoftAccount;
    clientBuilder = clientBuilder.WithAuthority(AzureCloudInstance.AzurePublic, authority);
}

Then we should be good to go 👍

@brekkjen
Copy link
Contributor Author

brekkjen commented Dec 9, 2021

Yes, i agree.

@shweaver-MSFT shweaver-MSFT merged commit 14b8c15 into CommunityToolkit:main Dec 10, 2021
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

Successfully merging this pull request may close these issues.

[Feature] Enable the possibility to specify TenantId
2 participants