Reputation: 1
I am new to using this type of trying to get the user details in my org using python flask server by hitting the URL : https://graph.microsoft.com/v1.0/me/ Request headers: 'Content-Type': "application/json", 'Authorization': accessToken Response:
The page you requested has been blocked
any suggestions please?From the graph URL , able to get the response from python code base we got the Access Denied. method in python:
enter code here
def get_user_details_(access_token: str): url = "https://graph.microsoft.com/v1.0/me" headers = {'Content-Type': "application/json", 'Authorization': access_token } response = requests.get(url, headers=headers, verify=False) print("response **** ", response.text) response = response.json() if response else {} return response
Upvotes: 0
Views: 366
Reputation: 1
I found the answer. It is related to Proxy. We need to add proxy details to request object.
proxyDict = { "http": "http proxy address", "https": "https proxy address" }
response = requests.request('GET', url, headers=headers, proxies=proxyDict, verify=False)
Upvotes: 0
Reputation: 4893
To resolve the above issue, We can follow the below workaround;
OUTPUT RESULT FOR REFERENCE:-
For complete setup please refr this BLOG|Querying Microsoft Graph API with Python by @Ephraim Mwai.
Upvotes: 0