问题描述
OAuth Token 工具完成授权后,可以成功获取 access_token 和 refresh_token,但点击写入/添加账号时,后端写入前 token 校验失败:
AADSTS70000: The request was denied because one or more scopes requested are unauthorized or expired.
同一个 refresh_token 使用手动格式导入账号可以成功:
邮箱----密码----client_id----refresh_token
复现条件
授权链接使用 Graph 命名 scope,例如:
Mail.Read User.Read offline_access openid profile
Token 工具写入账号时,后端校验逻辑未使用本次授权 scope,而是回退到默认/兼容 scope,导致 Microsoft token endpoint 认为请求了未授权 scope。
预期行为
Token 工具写入账号前校验 refresh token 时,应优先使用本次 OAuth 授权实际请求/返回的 scope。
实际行为
写入前校验使用默认兼容 scope,导致 refresh token 本身有效但校验失败。
影响
- Token 工具获取 token 成功但无法一键写入账号
- 用户只能绕过工具手动导入
- 错误提示容易误导为 refresh token 无效
修复方向
- 前端保存账号 payload 携带本次 token 结果中的
requested_scope / granted_scope
- 后端
save_to_account 优先使用显式 scope 校验
- 未传 scope 的旧调用保留原默认兼容行为
问题描述
OAuth Token 工具完成授权后,可以成功获取
access_token和refresh_token,但点击写入/添加账号时,后端写入前 token 校验失败:同一个
refresh_token使用手动格式导入账号可以成功:复现条件
授权链接使用 Graph 命名 scope,例如:
Token 工具写入账号时,后端校验逻辑未使用本次授权 scope,而是回退到默认/兼容 scope,导致 Microsoft token endpoint 认为请求了未授权 scope。
预期行为
Token 工具写入账号前校验 refresh token 时,应优先使用本次 OAuth 授权实际请求/返回的 scope。
实际行为
写入前校验使用默认兼容 scope,导致 refresh token 本身有效但校验失败。
影响
修复方向
requested_scope/granted_scopesave_to_account优先使用显式 scope 校验