How can I specify WithAppOnly() globally for a GraphServiceClient, so I don't have to specify it for every single Microsoft Graph request?
Consider the following code:
var c = app.Services.GetRequiredService<GraphServiceClient>();
await c.Users.GetAsync(r => r.Options.WithAppOnly());
The WithAppOnly()
instructs the GraphServiceClient
to use app-only permissions for Microsoft Graph instead of user permissions.
I wish to specify this globally for the GraphServiceClient
, so I don't have to specify it for each request. Is this possible?
#calling-a-web-api-from-a-daemon-application