python-3.x secureScores端点返回None

e5nqia27  于 2023-11-20  发布在  Python
关注(0)|答案(1)|浏览(131)

我正在使用Microsoft Graph API(python3)。get_alerts()get_secure_score_control_profiles()返回结果,但get_secure_score()返回'None'
Azure门户显示安全分数,但尽管响应状态为200,函数仍返回。有指针吗?

def get_secure_score():

    base_url = 'https://graph.microsoft.com/beta/security/secureScores'
    #or 
    #base_url = 'https://graph.microsoft.com/v1.0/security/secureScores'
    secure_scores = MSGRAPH.get(base_url).json()
    print(secure_scores)
    secure_scores = secure_scores.json()
    print(secure_scores)

    if b'' in secure_scores:
        print("Please Sign-in using a on.microsoft.com account for demo data")
        secure_scores = None
    elif 'error' in secure_scores:
        secure_scores = None
    elif len(secure_scores.get('value')) > 0:
        secure_scores = secure_scores.get('value')[0]
    else:
        secure_scores = None
    return secure_scores

字符串

  • 网址:https://graph.microsoft.com/beta/security/secureScores
  • 响应:Response [200]
  • 响应输出:
{
  '@odata.context': 'https://graph.microsoft.com/beta/$metadata#Security/secureScores', 
  'value': []
}
m0rkklqb

m0rkklqb1#

当你第一次在Azure上注册应用时,你的安全分数可能不会立即可用,但你仍然会有其他信息,如警报和控制配置文件。如果你仍然没有获得安全分数数据,你也可以联系并提交Github issue here

相关问题