I have delegated access set up with permissions in the Azure Portal for Files.ReadWrite.All.

My user is signed into the app with their Microsoft Entra ID. My app service is set up in Microsoft Entra ID delegated permissions for Files.ReadWrite.All are added for the app registration Using Microsoft Graph 5.0

The first call returns the user model. But the 2nd call with "Me.Drive" throws an Item Not Found exception.

var defaultCredential = new DefaultAzureCredential(); GraphServiceClient client = new GraphServiceClient(defaultCredential); var user = await client.Me.GetAsync(); var mydrive = await client.Me.Drive.GetAsync();

Here is my configuration out of my Startup.cs:

public void ConfigureServices(IServiceCollection services) { services.Configure<CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.Unspecified; // Handling SameSite cookie according to https://docs.microsoft.com/en-us/aspnet/core/security/samesite?view=aspnetcore-3.1 options.HandleSameSiteCookieCompatibility(); }); services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme) .AddMicrosoftIdentityWebApp(options => Configuration.Bind("AzureAd", options)) .EnableTokenAcquisitionToCallDownstreamApi() // This is needed to exchange the authorization code for an ID Token .AddInMemoryTokenCaches(); services.AddControllersWithViews(options => { var policy = new AuthorizationPolicyBuilder() .RequireAuthenticatedUser() .Build(); options.Filters.Add(new AuthorizeFilter(policy)); }).AddMicrosoftIdentityUI(); services.AddHttpClient<MRBController>(); services.AddRazorPages(); //Configuring appsettings section AzureAd, into IOptions services.AddOptions(); }

Adam's user avatar

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.