【问题标题】:One Note API The request does not contain a valid authentication tokenOne Note API 请求不包含有效的身份验证令牌
【发布时间】:2020-11-01 14:56:35
【问题描述】:

我正在尝试与学生共享一个笔记课堂笔记本,但遇到了权限问题。我已经添加了 Azure APP 中所需的所有权限。我正在获取访问令牌,刷新令牌,其范围为Notes.ReadWrite.All

方法:-

public static async Task<string> AssignNotebookToStudent(string studentEmail, string fileId)
        {
            var payload = new
            {
                id = studentEmail,
                principalType = "Person"
            };
            
            using (var client = new HttpClient())
            {
                client.DefaultRequestHeaders.Add("Authorization", $"Bearer {tokenValue}");
                client.DefaultRequestHeaders.Add("accept", "application/json");
                var result = await client.PostAsJsonAsync($"https://www.onenote.com/api/v1.0/me/notes/classNotebooks/{fileId}/students", payload);
                var responseString = await result.Content.ReadAsStringAsync();
                return responseString;
}

获取权限响应错误

API Docs

【问题讨论】:

    标签: c# asp.net-mvc microsoft-graph-api onenote-api


    【解决方案1】:

    通过获取身份验证访问令牌添加范围 scope=Notes.Create Notes.Read Notes.ReadWrite

    猜你喜欢
    • 1970-01-01
    • 2023-03-29
    • 1970-01-01
    • 2017-06-30
    • 2014-08-17
    • 2020-08-18
    • 2017-07-20
    • 2020-01-15
    • 2016-10-19
    相关资源
    最近更新 更多