首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >公有云上的应用程序可以通过图形api从政府租户那里获取数据吗?

公有云上的应用程序可以通过图形api从政府租户那里获取数据吗?
EN

Stack Overflow用户
提问于 2020-10-07 00:04:50
回答 1查看 245关注 0票数 1

我正在尝试通过图形api从政府租户那里获取电子邮件列表,直到上周都运行得很好。我正在使用客户端凭据流。上周,当我尝试在政府租户中授权我的应用程序时,我开始收到以下错误:

oauthlib.oauth2.rfc6749.errors.InvalidClientIdError: (invalid_request) AADSTS900441: Requests to applications hosted in the public cloud are not supported for USGov tenants.

有没有办法授权来自公共azure云的应用程序从政府租户那里读取数据?

编辑:代码示例和调试日志

代码语言:javascript
运行
复制
    from oauthlib.oauth2 import BackendApplicationClient
    
    client = BackendApplicationClient(client_id=config.CLIENT_ID)
    MSGRAPH = requests_oauthlib.OAuth2Session(
        client=client
    )
    
    token = MSGRAPH.fetch_token(
        'https://login.microsoftonline.us' + '/<tenant>' + config.TOKEN_ENDPOINT,
        client_id=config.CLIENT_ID,
        client_secret=config.CLIENT_SECRET,
        include_client_id=True,
        scope=['https://graph.microsoft.us/.default'])

    endpoint = config.RESOURCE + config.API_VERSION + '/users'
    graphdata = MSGRAPH.get(endpoint).json()
代码语言:javascript
运行
复制
DEBUG:requests_oauthlib.oauth2_session:Requesting url https://login.microsoftonline.us/<tenant-id>/oauth2/v2.0/token using method POST.
DEBUG:requests_oauthlib.oauth2_session:Supplying headers {u'Content-Type': u'application/x-www-form-urlencoded;charset=UTF-8', u'Accept': u'application/json'} and data {u'client_secret': u'...', u'grant_type': u'client_credentials', u'client_id': u'...', u'scope': u'https://graph.microsoft.us/.default'}
DEBUG:requests_oauthlib.oauth2_session:Passing through key word arguments {'verify': True, 'json': None, 'proxies': None, 'timeout': None, 'auth': None}.
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): login.microsoftonline.us:443
DEBUG:urllib3.connectionpool:https://login.microsoftonline.us:443 "POST /<tenant-id>/oauth2/v2.0/token HTTP/1.1" 400 522
DEBUG:requests_oauthlib.oauth2_session:Prepared fetch token request body grant_type=client_credentials&client_id=...&client_secret=...&scope=https%3A%2F%2Fgraph.microsoft.us%2F.default
DEBUG:requests_oauthlib.oauth2_session:Request to fetch token completed with status 400.

基本上,当我试图获取访问令牌时,我会看到这个错误。租户管理员已经对我的申请给予了管理员同意。这段代码为Gov租户工作了几个月左右,然后突然停止了工作。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-10-12 22:45:23

AAD大约一个月前开始执行这一规定,GCC高/国防部租户不能使用商业云中发布的机密应用程序。您需要从GCC高/国防部租户发布您的应用程序。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64229652

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档