Microsoft Graph API 工作帐户授权 Note.Read 范围需要管理员批准

Microsoft Graph API Work Accounts authorize with Note.Read scope need admin approval

我正在尝试使用 Microsoft Graph API V2.0 访问用户的 OneNote 笔记本。

我正在尝试使用以下 link 示例通过 OAuth 进行授权:

https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize?
    response_type=code
    &client_id={id}
    &redirect_uri={url}
    &scope=Notes.Read%20offline_access
    &state={state}

当我使用工作帐户登录时,我收到一条消息:

{app_name} needs permission to access resources in your organisation that only an admin can grant. Please ask an admin to grant permission to this app before you can use it.

并且:

Message: AADSTS90094: The grant requires admin permission.

使用管理员帐户我没有问题。

来自 Notes permissions、none 个注释范围(即 Notes.ReadNotes.ReadWriteNotes.CreateNotes.ReadWriteAll需要管理员同意

这有什么理由要求管理员权限吗?

当 Azure AD instance/tenant 禁用 "Users can consent to apps accessing company data on their behalf" 时会发生这种情况。这是 Azure AD 中的全局用户设置:

当此选项设置为 No 时,将阻止用户执行 User Consent 流程:

为了解决这个问题,管理员要么需要代表用户同意,要么他们需要 re-enable 用户同意选项(这是推荐的解决方案,几乎没有理由完全关闭用户同意)。

我们写了一篇关于 need admin approval issue 的详细文章,解决了最常见的情况。我怀疑问题已在第一部分中解决,您的 IT 管理员需要允许用户请求访问。