✅ C# Graph API Client
I'm trying to access all of the items in a sharepoint list. I'm just getting an access denied error right now. Using the same site id and list id I can use my account to grab the items, but using the app I can't
I think I might need to use the AllowAppOnly flag, but I have no clue how to do that. Anyone go any ideas?
16 Replies
have you tried with graph explorer
Yes, but I could only do it with my account permissions (which worked).
The problem is that the application permission isn't working 😦
how are the app permissions configured
Azure App with
Sites.FullControl.All permission enabled
Then in the code above I show how I implement the client
I am able to query for all users, but not for the items in a list
yeah but for example does it require admin consent?
i believe it doesn't so it should be ok from that point of view
was it created as delegate or app?
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.I added the permissions as an application permission and got it approved by an admin. When you say "was it created as delegate or app", does that mean that when creating the app you select what kind of app it will be between those two?
no i mean delegate permission or app permission
because even if you create an app registration the api permissions needed to do stuff could be those in add permission -> microsoft graph -> delegate permission
just be sure to be using the correct ones
,Ahhhh yes I'm definitely using app permissions right now. The reason being is that this is supposed to be an automated process and shouldn't require a user to sign in
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.do you have your access token?
Since I’m using the client secret credential I didn’t find a property on there for access token. I’ll look into it in a bit, but I’m pretty sure it doesn’t provide me with one
the base is this, right?
https://learn.microsoft.com/en-us/graph/sdks/choose-authentication-providers?tabs=csharp
Choose a Microsoft Graph authentication provider - Microsoft Graph
Learn how to choose scenario-specific authentication providers for your application.
so you could follow this tutorial maybe
https://learn.microsoft.com/en-us/graph/tutorials/dotnet-app-only?tabs=aad&tutorial-step=3
Build .NET apps with Microsoft Graph and app-only authentication - ...
In this tutorial, you'll build a .NET app that uses the Microsoft Graph API to access data using app-only authentication.
also this, it's redundant but you know
https://learn.microsoft.com/en-us/graph/auth-v2-service?tabs=http#4-request-an-access-token
Get access without a user - Microsoft Graph
Learn how an app obtains an access token from the Microsoft identity platform and calls Microsoft Graph with its own identity.
Ooooo thanks for all these resources - you were right about the permissions. After another closer look I had the right name for the permission, but I had the SharePoint API Sites.ReadWrite.All NOT the Graph API one
As soon as I added in the Graph API Sites.ReadWrite.All permission it started working
Thanks for time and help on this 🙂