Share via

Send email using latest Graph client package

lakshmi 821 Reputation points
2024-07-10T17:40:28.94+00:00

We are using a multi tenant application.

App registration is created in Tenant A and the same bot application is used by Tenant B customers also.

So we want to use the same app registration for Tenant B also to send email.

It was working till the graph client version 4 using the sign in process. We will get the token when user sign in and if its a different tenant user, then it will ask for accepting the app registration and valid token will be created.

We have used the same token to create the graph client in the latest nuget version and we were getting unauthorized error

Same can we achieve using the application permission

Or can we use the below code in the document, https://learn.microsoft.com/en-us/graph/sdks/choose-authentication-providers?tabs=csharp#on-behalf-of-provider

// Multi-tenant apps can use "common",
// single-tenant apps must use the tenant ID from the Azure portal
var tenantId = "common";
// Value from app registration
var clientId = "YOUR_CLIENT_ID";
var authenticationProvider = new BaseBearerTokenAuthenticationProvider(
    new IntegratedWindowsTokenProvider(clientId, tenantId));
var graphClient = new GraphServiceClient(authenticationProvider);
return graphClient;


Microsoft Security | Microsoft Graph
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 46,431 Reputation points
    2024-07-15T10:17:12.6266667+00:00

    Hi @lakshmi

    Do you mean to create an unattended application context using the "common" endpoint?

    Then the answer is "no", application contexts do not support "common" endpoints, only "tenant_id" endpoints. The "common" endpoints are only available for delegated contexts to log in users from different tenants.

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.