我是MS Graph API的新手,并试图使用在Azure AD中注册的MS Graph检索SharePoint列表项。我能够通过传递以下参数(client_id,client_secret,资源,授权)来检索访问令牌,因此问题出在运行api url时:邮递员https://graph.microsoft.com/v1.0/sites/{{site-id}}/lists/{{list-id}}/items?$Select=Id&$expand=fields($select=Title)
(通过在Header中传递Bearer-access令牌)。
我收到以下错误消息,指出“ 令牌中必须包含scp或角色声明”。如果您能指导我提供正确的解决方案,因为我正在尝试使用api,那将是非常不错的选择使用C#并收到以下错误,指出“ 403-Forbidden”
using (var client = new HttpClient())
{
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "https://graph.microsoft.com/v1.0/sites/{{site-id}}/lists");
request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);
var response = client.SendAsync(request).Result;
//var result = requestTask.Result;
if (response.IsSuccessStatusCode)
{
var readTask = response.Content.ReadAsStringAsync();
readTask.Wait();
Console.WriteLine("Response:" + readTask);
}
}