Hotmail access via Graph API - Forbidden / Target resource hosted on database is currently on backend 'Unknown'
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