0

I am getting access token from user with the scopes that I need which are Files.Read as shown below

stdClass Object
(
[token_type] => Bearer
[scope] => Files.Read Files.Read.All Files.ReadWrite.All Mail.Read Sites.Read.All User.Read profile openid email
[expires_in] => 3599
[ext_expires_in] => 3599
[access_token] => eyJ0eXAiOiJKV1QiLCJub25j // i have shorten this access token
[refresh_token] => 0.AWQA4RhkkXBq2kqvIbqr05RTbr8vC // i have shorten this refresh token
)

My problem is when I call /me/drive/root/children API it gives me empty result as shown below,

stdClass Object
(
[@odata.context] => https://graph.microsoft.com/v1.0/$metadata#users('ae496a8e-f1b1-4e1c-83df-xxxxxxxxxxxx')/drive/root/children
[value] => Array()
)

From the portal, I have given permission for Files.Read Files.Read.All Files.ReadWrite.All. But then also getting empty value. I have files in my one drive.

  • Check the token using https://jwt.ms and see what permissions/scopes you see in it – Dev May 31 '21 at 05:52
  • Also just to isolate the issue, try using the same API call with Microsoft Graph explorer and see if you can repro the issue or not. – Dev May 31 '21 at 05:53
  • @Dev on jwt.ms, i have check the token, it has the scopes that are required. And I tried same on Graph explorer it works there. – Anand Bhagat May 31 '21 at 08:49
  • I tried both the code sample and graph explorer - both works for me. Ok, i see a difference, check it out and see if it helps. When i make the API call, i https://graph.microsoft.com/v1.0/me/drive/root/children. In your scenario, you're using https://graph.microsoft.com/v1.0/$metadata#users('ae496a8e-f1b1-4e1c-83df-xxxxxxxxxxxx')/drive/root/children. I believe the above user is the me/current logged user or same user you tested with Graph explorer. So check the above, test it against me endpoint and see if it makes any difference. – Dev Jun 02 '21 at 06:03

0 Answers0