繁体   English   中英

Azure Active Directory 返回 403 作为访问被拒绝

[英]Azure Active directory return 403 as Access denied

我是新来使用这种类型的尝试通过点击 URL 来获取我的组织中的用户详细信息: https ://graph.microsoft.com/v1.0/me/ 请求标头:'Content-Type' :“应用程序/json”,“授权”:accessToken 响应:

拒绝访问

您请求的页面已被阻止

请问有什么建议吗?

从图 URL 中,能够从 python 代码库获得响应,我们得到了拒绝访问。 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

在此处输入图像描述

要解决上述问题,我们可以按照以下解决方法;

  • 确保您具有为您的应用程序授予的以下权限,以便在调用 API 时能够读取并给出所需的结果。

在此处输入图像描述

输出结果供参考:-

在此处输入图像描述

有关完整设置,请参考@Ephraim Mwai的这篇博客|Querying Microsoft Graph API with Python

我找到了答案。 它与代理有关。 我们需要向请求对象添加代理详细信息。

proxyDict = { "http": "http 代理地址", "https": "https 代理地址" }

response = requests.request('GET', url, headers=headers, proxies=proxyDict , verify=False)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM