Skip to content

Allow registration of multiple graph clientsΒ #2927

@LadislavBohm

Description

@LadislavBohm

Is your feature request related to a problem? Please describe the problem.

I have ASP.NET Core API with Graph API added into DI like this:

services.AddMicrosoftGraph(options => configuration.GetSection("DownstreamApis:MicrosoftGraphDelegated").Bind(options));

This works fine and I'm able to inject GraphServiceClient and call Graph API with users delegated permissions. However some calls I want to make using application permissions (ConfidentialApplication). I was hoping to register them both:

services.AddMicrosoftGraph(options => configuration.GetSection("DownstreamApis:MicrosoftGraphDelegated").Bind(options)); services.AddMicrosoftGraph(options => configuration.GetSection("DownstreamApis:MicrosoftGraphApplication").Bind(options));

But looking at the source code it looks like they override each other. Is it possible to add overload to allow keyed registration? Or factory helper to handle this scenario? Because some useful classes are internal and can't be used.

Or I'm open to other way of handling this scenario.

Describe the solution you'd like.

I would like to be able to use keyed service registration or generic overload which would specify context for DI registration. This way I could register multiple graph clients with different configurations (scopes, delegated/application etc...)

Additional context?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions