microsoftgraph / microsoftgraph/msgraph-sdk-java

Guest User Receives 401 "accessDenied" Error When Accessing Shared Files via Microsoft Graph API Despite Valid Authentication

Open
#2,518 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status:waiting-for-triage
Dominant language
Java
Stars
444
Forks
154
Avg merge
18h 28m
Merged PRs (30d)
4

Description

Refernce similar to this in Sharepoint: https://github.com/OneDrive/onedrive-api-docs/issues/1039

Pattern of failure:
Initial API calls fail with 401
After manually visiting the file through SharePoint web UI, API calls work temporarily (1-4 hours)
API calls then fail again after a period of inactivity
Web UI access requires device code authentication flow
What works:
✅ Basic Microsoft Graph calls (/me) succeed
✅ Accessing files through SharePoint web UI works
✅ Token refresh succeeds and produces valid access tokens
What fails:
❌ Microsoft Graph API calls to /shares/{share-id}/driveItem

Issue Type: Microsoft Graph API Authentication
Affected Service: SharePoint Online for Business
User Type: Guest User (External/Cross-Tenant)
Authentication Method: OAuth 2.0 with Refresh Token
API Endpoint: /shares/{share-id}/driveItem

Problem Description:
As a guest user in your tenant, I am unable to programmatically access shared files via the Microsoft Graph API, despite having:

Valid authentication tokens
Proper API permissions granted
Ability to access the same files through the web UI

Detailed Symptoms:

API calls fail with 401 error:

{
"error": {
"code": "accessDenied",
"message": "There has been an error authenticating the request."
}
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source files or tests are named. Start by reproducing the /shares/{share-id}/driveItem request with a guest user's refreshed token, then compare it with /me and SharePoint web UI access, using the linked SharePoint issue as context. Done requires a documented cause and a validated resolution for the recurring 401 response.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, authentication, cloud
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.