Hello everyone, I want to download an excel file that is shared across users of our company in onedrive. I am using application permissions (so not on behalf of) and I'm able to get an access_token.
With the token I'm able to list users with a get request to the "/users" endpoint and grab the id of the original owner of the file, but then when I try to access the file with
GET /users/{userId}/drive/items/{item-id}/content
I get "access denied"
What am I missing?
EDIT:
Everything I've done:
- Registered my app in microsoft entra
- Generated client secret
- With client secret, request a token and store it in the db
base_uri "https://login.microsoftonline.com"
options = {
headers: { "Content-Type" => "application/x-www-form-urlencoded" },
body: {
client_id: ENV["CLIENT_ID"],
scope: "https://graph.microsoft.com/.default",
client_secret: ENV["CLIENT_SECRET"],
grant_type: "client_credentials",
},
}
response = post("/#{ENV["TENANT_ID"]}/oauth2/v2.0/token", options)
- With token, list users and grab the id of the original creator of the file