Hotmail access via Graph API - Forbidden / Target resource hosted on database is currently on backend 'Unknown'

Mike 1 Reputation point
2021-03-13T01:27:15.243+00:00

Hi

I am trying to access the emails from my personal Hotmail account via the Graph API.

I have registered an application in Azure and granted it the necessary permissions from Mail.x and User.x

I set the supported account type to 'Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)'

Minimal python script:

tenant = 'xxx'
app_id = 'xxx'
app_password = 'xxx'
userAccount = '{user.id}'

resource_URL ='https://graph.microsoft.com'
authority_url = 'https://login.microsoftonline.com/%s'%(tenant)

context = adal.AuthenticationContext(authority_url)
token = context.acquire_token_with_client_credentials(resource_URL, app_id, app_password)
request_headers = {'Authorization': 'bearer %s'%(token['accessToken'])}

message_URL = 'https://graph.microsoft.com/v1.0/users/{user.id}/messages'
result = requests.get(message_URL, headers = request_headers)

It returns a 503 response and the message 'Target resource 'xxxxxxxx-xxxx-xxxx-0000-000000000000' hosted on database 'xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx' is currently on backend 'Unknown'. (Redacted)

The Graph Explorer works just fine. I believe the issue is with my configuration within Azure since I get the 503 status from a Javascript call too. I really don't know what I am missing though...

Thanks in advance

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,663 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,581 questions
{count} votes