0
votes

I am Working on python script to backup files from users office 365 onedrive. I use Graph API to get an object list from users onedrive. My query for getting all child objects from the root drive of a user returns the expected values in Graph Explorer. When using the same query in the python script Graph returns an empty value. Other queries in the script are returning correct values.

Example of query returning correct value: https://graph.microsoft.com/v1.0/users/xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx/drives Script extracts drive-id from return value to get list of child-objects from next query: https://graph.microsoft.com/v1.0/users('xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx')/drives('xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx')/root/children

Returns empty value from API call but returns correct value from Graph explorer.

Any suggestions?

1
Are you making calls against OneDrive Business users? What scopes did you request in your token?Brad

1 Answers

1
votes

you need to add appropriate permissions to graphScopes variable

I was trying to fetch the list of one drive files using javascript code then I was using this config

var applicationConfig = {
clientID: "ea5*****-c721-4f13-a***-369f8c******",
graphScopes: ["user.read"],
graphEndpoint: "https://graph.microsoft.com/v1.0/me",
webApi : "https://graph.microsoft.com/v1.0/me/drive/root/children"
};

It was giving empty list but then I changed graphScopes in the config

var applicationConfig = {
clientID: "ea5*****-c721-4f13-a***-369f8c******",
graphScopes: ["Files.Read.All","Sites.Read.All"],
graphEndpoint: "https://graph.microsoft.com/v1.0/me",
webApi : "https://graph.microsoft.com/v1.0/me/drive/root/children"
};

then it gave me the list that it was giving in GraphExplorer