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

Add support for tenant selection when using AppOnly Microsoft Graph #790

Merged
merged 1 commit into from
Nov 30, 2020

Conversation

hajekj
Copy link
Contributor

@hajekj hajekj commented Nov 27, 2020

When using AppOnly call with multi-tenant application, you won't be able to obtain the token for target tenant due to not being able to choose the tenant. This pull request adds support to explicitly choose tenant when obtaining an app-only token like this:

var organization = await _microsoftGraph.Organization
    .Request()
    .WithAppOnly(tenant: "thenetw.org") // or tenantId
    .GetAsync();

@ghost
Copy link

ghost commented Nov 27, 2020

CLA assistant check
All CLA requirements met.

Copy link
Collaborator

@jmprieur jmprieur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Thanks @hajekj. This is a good addition/scenario.

return SetParameter(baseRequest, options =>
{
options.AppOnly = appOnly;
options.Tenant = tenant;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to throw an ArgumentException if tenant is 'common' or 'organizations' as these should not be used.
cc: @jennyf19, @bgavrilMS

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmprieur i'll merge but we should implement your suggestion before a release.

Copy link
Collaborator

@jennyf19 jennyf19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

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.

3 participants