Is it possible to let others upload files to my onedrive without a login?

Alex Ch 0 Reputation points
2023-06-16T21:21:35.3866667+00:00

I have a project with React, which I need to send a file to my OneDrive. It is effortless, the users fill out a form and attach a file; that file has to be sent to my Onedrive. I was wondering if it is possible to upload the file without a login, like having a default access token and refreshing it every time it`s needed.

Excuse my poor choice of words

Microsoft 365 and Office | OneDrive | For business | Windows
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Manu Philip 20,206 Reputation points MVP Volunteer Moderator
    2023-06-16T21:31:31.25+00:00

    It is possible to upload files to an OneDrive account via Graph API in the following method

    1. Create Azure AD application to use for the purpose
    2. Configure Permissions for the application

    Microsoft graph -> Application Permissions -> Files.ReadWrite.All, Sites.ReadWrite.All

    1. Get access token and use it in the following command
    ACCESS_TOKEN=htI2eXAiOiJ7R4QiNMKub25jZSI6IlZ0KYRT
    
    curl -X PUT 'https://graph.microsoft.com/v1.0/me/drive/root:/foldername/file.tgz:/content' -H 'Authorization: Bearer '"${ACCESS_TOKEN}"'' -T test.tgz
    
    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.