Unable to share file sharepoint site using graph api to external user using client credentials

zpy978 11 Reputation points
2025-04-29T06:17:55.6366667+00:00

I have a multitenant application i have followed the steps mentioned in the below

https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-client-creds-grant-flow

created the app registration in tenant a with the follow app permissions

Read and write directory data

Read and write all external user profiles

Read files in all site collections

Read and write files in all site collections

Have full access to the application's folder without a signed in user.

Read and write your organization's external identities policy

Read and write items in all site collections

Invite guest users to the organization

Read all users' full profiles

Read and write all users' full profiles

Sign in and read user profile

provided admin consent in tenant b, tenant b is where the site is and from where graph api will invite users to view/edit files.

I am successfully able to get the site drive and upload files using graph api.

I could successfully send invite to view/edit files to users that belong to same tenant b domain

       `var response = await graphClient`

.Drives[drive.Id]

.Items[request.FileId]

.Invite

.PostAsInvitePostResponseAsync(requestBody, cancellationToken: cancellationToken);

Requirement is also to send invite to view/edit files to external users (not belonging to tenant b domain ) example personal accounts and other work accounts although the above works fine for same domain users of tenant b it fails for all other recipients work or personal email not part of tenant b domain.

The exception does not have any specific details just An unspecified error has occurred.

Please let me know what other permission is missing to be able to send file sharing invite to external users in a multi tenant application.

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,431 questions
0 comments No comments
{count} votes

Your answer

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