Tried to download file from onedrive but InvalidAuthenticationToken

Xinyuan Ma 0 Reputation points
2023-06-07T13:35:12.85+00:00

Hey,

I acquired the filenames and successfully downloaded the files using Graph API by python script.

However, the files are all 1KB in size and cannot be opened.

I examined the response returned by my GET request:

"error": {"code": "InvalidAuthenticationToken", "message": "Access token is empty."}

It's strange because I utilized the same headers to retrieve the filename and all the related information.

Could you kindly provide assistance?

Thank you.

Xinyuan

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

1 answer

Sort by: Most helpful
  1. Mehtab Siddique (MINDTREE LIMITED) 971 Reputation points
    2023-06-14T09:17:03.59+00:00

    This error is mainly caused if in your login request, the resource parameter is not https://graph.microsoft.com

    The response should be:

    User's image

    For more information:https://learn.microsoft.com/en-us/graph/api/driveitem-get-content?view=graph-rest-1.0&tabs=python#response


    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.