如果我去https://developer.microsoft.com/en-us/graph/graph-explorer#并使用如下 URL:
现在,如果我使用来自 github https://github.com/AzureAD/microsoft-authentication-library-for-js的 Angular 应用程序
和像这样的代码
private sharePointHost: string = "https://4development106.sharepoint.com/sites/DBSchenker/_api/web/lists/getByTitle('OEC_Docs')/items"
getDocuments(token){
const httpOptions = {
headers: new HttpHeaders({
'Accept': 'application/json;odata=verbose'
,'Authorization' : "Bearer " + token
})
};
this.http.get(this.sharePointHost, httpOptions).subscribe(
(resp) => console.log("respon is::: " + JSON.stringify(resp)),
(err) => console.log("error:::" + JSON.stringify(err))
)
}
它抛出:
error:::`{"headers":{"normalizedNames":{},"lazyUpdate":null},"status":401,"statusText":"OK","url":"https://4development106.sharepoint.com/sites/DBSchenker/_api/web/lists/getByTitle('OEC_Docs')/items","ok":false,"name":"HttpErrorResponse","message":"Http failure response for https://4development106.sharepoint.com/sites/DBSchenker/_api/web/lists/getByTitle('OEC_Docs')/items: 401 OK","error":{"error_description":"Invalid JWT token. No certificate thumbprint specified in token header."}}`
将主机更改为(在图形 api 资源管理器中工作)
private sharePointHost: string = "https://graph.microsoft.com/beta/sites/4development106.sharepoint.com:/sites/DBSchenker:/lists/OEC_Docs/items"
投掷
error:::{"headers":{"normalizedNames":{},"lazyUpdate":null},"status":401,"statusText":"Unauthorized","url":"https://graph.microsoft.com/beta/sites/4development106.sharepoint.com:/sites/DBSchenker:/lists/OEC_Docs/items","ok":false,"name":"HttpErrorResponse","message":"Http failure response for https://graph.microsoft.com/beta/sites/4development106.sharepoint.com:/sites/DBSchenker:/lists/OEC_Docs/items: 401 Unauthorized","error":{"error":{"code":"InvalidAuthenticationToken","message":"Access token validation failure.","innerError":{"request-id":"f5a77afc-0d92-49a0-92c4-e727e056d0a9","date":"2018-10-30T01:42:02"}}}}
不知道我做错了什么