Sep-12-2022, 09:10 PM
I am fairly new to python. I have been working on this for a few weeks. A previous employee used basic authentication to access email on our exchange server. According to Microsoft this is going away October 1st. I am working on using modern authentication, and am having no luck. I have looked through Microsoft's documentation on this, and it did not help. I have searched the web, to no avail. I am able to get an access token, but when I try to access the email box I get a 400 response instead of 200. Below is the code snippet that appears to be the problem, and the code I use to get the access token, incase that helps. The ConfidentialClientApplication actually does have the proper data, and the <user> is the actual username.
The error that I am receiving is below.
'error': {'code': 'Request_BadRequest', 'message': 'Unexpected segment DynamicPathSegment. Expected property/$value.'
I would greatly appreciate any help, or even some sort of clear documentation or examples that you could provide.
Thank you for taking the time to read this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
app = ConfidentialClientApplication( "", authority = "", client_credential = "" ) result = None if not result: if "access_token" in result: print (result[ "token_type" ]) else : print (result.get( "error" )) print (result.get( "error_description" )) print (result.get( "correlation_id" )) # You might need this when reporting a bug. print (result[ "access_token" ]) headers = { 'Authorization' : 'Bearer ' + result[ "access_token" ] } # Step 2. Retrieve emails response = requests.get( 'https://graph.microsoft.com/v1.0/users/<user>/mailFolder/inbox/messages' , headers = headers) print (response.json()) if response.status_code ! = 200 : raise Exception(response.json()) |
'error': {'code': 'Request_BadRequest', 'message': 'Unexpected segment DynamicPathSegment. Expected property/$value.'
I would greatly appreciate any help, or even some sort of clear documentation or examples that you could provide.
Thank you for taking the time to read this.