I'm currently using the REST API to upload files/folders and share the files with other users.
Files/Folders are being uploaded to the following:
https://tenant-my.sharepoint.com/personal/username_tenant_onmicrosoft_com/
To allow me to do this I have added a Admin account as an owner to the users site. When I make any calls to the API they are done through the Admin account. I couldn't find any way of impersonating a user.
When I have finished uploading and sharing the files and go to remove the admin account from the site and then login as the user it still shows the Admin account as having full control. However I can change the permissions of each file and folder.
All other permissions applied are there which is what I want.
Is there a cleaner way of doing this? Can I impersonate a user through the REST API?