简体   繁体   中英

Is it possible to get SharePoint app-only principal for one site only using REST API?

There are many tutorials how to add principal for specific app manually for admin, like this: https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs

And it is okay it works. But is there a way to grant this principal with an API call instead of manual setup? It will still be requested with admin bearer token so it should have all permissions to set it up, but I can't find any way to do it.

There is a way, where if I have another app registered in my tenant with FullControl permissions it can use an API to give principals for other apps like this: https://docs.microsoft.com/en-us/graph/api/site-post-permissions?view=graph-rest-1.0&tabs=http

But I can't have another app and don't want it, I just want to use admin credentials to add an app principal to write to one specific SharePoint page with some API call so I can later control files in the site with my app. Is there a way to do it?

In short, the answer is NO .

When we use an admin account to sign into appregnew.aspx page, in fact we are using an app / principal which is created by Microsoft to get the access token which can be used to create your SharePoint App-only principal.

This official scenario is consistent with what you said you need to create an app first, and then use it to configure another app.

Therefore, it is expected. I'm afraid we can't bypass the first app creation for configuring other apps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM