79491814

Date: 2025-03-07 09:38:12
Score: 1.5
Natty:
Report link

\>To access OneDrive- Personal file using Graph API.

Below are files present in my OneDrive-Personal Account:

![enter image description here](https://i.imgur.com/doAahh0.png)

Initially, I registered **multi-tenant** Microsoft Entra ID Application with Support Account type: Accounts in any organizational directory (Any Microsoft Entra ID tenant - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox) and added `redirect_uri: https://jwt.ms `:

![enter image description here](https://i.imgur.com/AqyDPwQ.png)

For accessing files needs to add **at least `Files.Read.All`** API permission, Added delegated type `Files.Read.All.All` API permission and Granted Admin Consent like below:

![enter image description here](https://i.imgur.com/aAeRUTv.png)

Using delegated type flow were user-interaction is required, so using authorization_code flow. Ran below authorization `code` request into browser:

```

https://login.microsoftonline.com/common/oauth2/v2.0/authorize?

client_id=<Client-Id>

&response_type=code

&redirect_uri=https://jwt.ms

&response_mode=query

&scope=https://graph.microsoft.com/Files.Read.All

&state=12345

```

This request prompt you for sign-in with your OneDrive-Personal account User like below:

![enter image description here](https://i.imgur.com/MuFTX9N.png)

After `Accept` you will get `authorization_code`:

![enter image description here](https://i.imgur.com/4BraDZu.png)

Now, Generate access token using below `Body` parameters:

```

GET https://login.microsoftonline.com/common/oauth2/v2.0/token

client_id: <APP_ID>

client_secret: <CLIENT SECRET>

scope:https://

grant_type:authorization_code

redirect_uri:https://jwt.ms

code:AUTHORIZATION_CODE_GENERATE_FROM_BROWSER

```

![enter image description here](https://i.imgur.com/Ay1Tdbb.png)

To access the OneDrive-Personal account file use below query with this generated access token:

```

GET https://graph.microsoft.com/v1.0/me/drive/root/children?select=name

Authoization: Bearer token

Content-type: application/json

```

**Response:**

![enter image description here](https://i.imgur.com/Y9aestH.png)

**Reference:**

[OneDrive in Microsoft Graph API](https://learn.microsoft.com/en-us/onedrive/developer/rest-api/?view=odsp-graph-online)

Reasons:
  • Blacklisted phrase (1): enter image description here
  • Long answer (-1):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Low reputation (0.5):
Posted by: Pratik Jadhav