Share via

How Can I Automate OneDrive Access and File Management using Python Script with Graph API?

Ron Anavi 0 Reputation points
2024-05-08T11:09:57.93+00:00

I am working on a Python script to automate file retrieval and deletion from OneDrive based on specific filters using Graph API. Since the script will run without interactive login, it requires an access token for authentication. Can someone provide detailed instructions or documentation on the exact steps I need to follow to accomplish this task? Thank you.

Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sourabh Gupta 805 Reputation points Microsoft External Staff
    2024-05-12T14:07:40.4966667+00:00

    Hi Ron Anavi,

    Thanks for reaching out.

    You need to acquire the token for the graph using Client id and client secret,

    You can refer to following link in order to get steps to do the same.

    https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-daemon-app-python-acquire-token

    Here they are creating an app registration and providing the relevant permissions to the created app registrations and then token is being acquired using the client id and secret. The same token can be used in order to make the Graph calls

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    0 comments No comments

Your answer

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