RestAPI使用Microsoftgraph进行威胁评估请求的问题

问题描述

我正在尝试与https://graph.microsoft.com/v1.0/informationProtection/threatAssessmentRequests

建立联系

得到以下错误: 401 {

错误”:{

"code": "Unauthorized","message": "required authentication information is either missing or not valid for the resource.","innerError": {

  "date": "2020-11-06T15:21:22","request-id": "8f4d480e-2916-4501-904b-0ca13db9e85e","client-request-id": "8f4d480e-2916-4501-904b-0ca13db9e85e"

我正在使用python3.7代码如下:

token ="xyz.dslkdskds_123"
headers = {
    "Content-type": "application/json","Authorization": "Bearer " + token
    }
query1={
  "@odata.type": "#microsoft.graph.urlAssessmentRequest","url": "info.cvx.com","contentType":"url","expectedAssessment": "block","category": "phishing"
}
url="https://graph.microsoft.com/v1.0/informationProtection/threatAssessmentRequests"
r = requests.post(url,headers=headers,data=json.dumps(query1))

解决方法

我在图浏览器中运行以下查询而没有必需的权限时遇到相同的问题

GET https://graph.microsoft.com/v1.0/informationProtection/threatAssessmentRequests

enter image description here

"error": {
    "code": "Unauthorized","message": "Required authentication information is either missing or not valid for the resource."

但是在提供了必要的权限ThreatAssessment.ReadWrite.All之后才能获取数据

enter image description here