For either OneDrive personal or business is it possible to have a single folder in OneDrive my app has access to without having access to all of OneDrive. Currently I am requesting permission from user to access all of Onedrive and setting this up manually, but users typically do not like giving access to all of OneDrive if its not a specific OneDrive app.
I feel like I have read about AppFolder permissions but I cannot find supporting documentation or examples of it being used.
The permission you're looking for is Files.ReadWrite.AppFolder
and it's documented in the file permissions category.
Description: Have full access to the application's folder (preview)
and (Preview) Allows the app to read, create, update, and delete files in the application's folder.
Once your application has an access token with this permission, your app folder is located at https://graph.microsoft.com/v1.0/me/drive/special/approot/
.
Uploading, downloading and listing the files is just like any other folder from this point. For example, listing the items in this folder is done with GET https://graph.microsoft.com/v1.0/me/drive/special/approot/children
.
Uploading a file:
PUT https://graph.microsoft.com/v1.0/me/drive/special/approot:/foo.txt:/content