繁体   English   中英

使用具有所有权限的应用程序时出现 ErrorAccessDenied

[英]ErrorAccessDenied when using app with all permissions

我正在使用来自

https://github.com/Azure-Samples/ms-identity-python-flask-webapp-call-graph#register-the-sample-applications-with-your-azure-active-directory-tenant

我添加了新功能来制作图形 api 调用

    def call_ms_graph_email_ext():
      ms_identity_web.acquire_token_silently() 
      graph = app.config['GRAPH_ENDPOINT_MAIL_EXT']
      token = f'Bearer {ms_identity_web.id_data._access_token}'
      results = requests.get(graph, headers={'Authorization': token}).json()
      length = len(results)
      print (results)
      return render_template('auth/call-graph-email.html', results=results)

在 app_config.py

GRAPH_ENDPOINT_MAIL_EXT = 'https://graph.microsoft.com/v1.0/users/mailbox1@company1.onmicrosoft.com/messages'

该应用程序具有应用程序用户的 Mail.Read 权限,在 aad.config.json 文件中没有定义 scope

"auth_request": {
    "redirect_uri": null,
    "scopes": [],
    "response_type": "code"
    },

示例代码中的图表 api 工作正常

GRAPH_ENDPOINT = 'https://graph.microsoft.com/v1.0/users'

mailbox1@company1.onmicrosoft.com 是我从 MS 365 管理中心创建的共享邮箱

我可以使用图形资源管理器访问图形 API 以获取消息。 当我使用应用程序时,我收到拒绝访问错误

{'error': {'code': 'ErrorAccessDenied', 'message': 'Access is denied. Check credentials and try again.'}}

有人可以建议这里有什么问题吗?

我在使用 flask 代码时遇到了一些问题,所以我使用了与

https://github.com/AzureAD/microsoft-authentication-library-for-python/blob/dev/sample/confidential_client_secret_sample.py

我的要求是我不需要用户交互的守护程序应用程序。

  1. Azure 身份验证部分中允许的公共客户端流。

  2. Mail.Read.Write MS 图 API - 应用程序权限

  3. 要求管理员同意 要求管理员为此应用程序创建限制策略规则https://docs.microsoft.com/en-us/graph/auth-limit-mailbox-access

  4. 经测试,我能够从图表 API 访问共享邮箱,但没有任何其他确认限制访问策略生效的邮箱

暂无
暂无

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

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