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

Azure Active Directory
Azure Active Directory
An Azure enterprise identity service that provides single sign-on and multi-factor authentication.
14,765 questions
Microsoft Graph Mail API
Microsoft Graph Mail API
A Microsoft API that supports accessing data in users' primary mailboxes and in shared mailboxes.
800 questions
Microsoft Graph Azure AD API
Microsoft Graph Azure AD API
A Microsoft API that queries the user's profile, finds other users, manages organizational relationships, tracks assignments, or creates original solutions that incorporate existing organizational data.
254 questions
{count} votes