OneDrive/SharePoint OAuth 无效受众错误
OneDrive/SharePoint OAuth invalid audience error
我的目标是编写一些代码,使 Office 365 用户能够通过 REST API 访问 OneDrive for Business 中的文件。我已经在 Azure AD(Web App/multi 租户)中注册了一个应用程序并添加了在线访问 SharePoint 的权限。我想使用 "delegated user identity with OAuth" 场景,我的应用程序使用用户模拟通过 REST APIs 访问 OneDrive for Business。
应用清单中的权限如下:
"oauth2Permissions": [
{
"adminConsentDescription": "Allow the application to access AppName on behalf of the signed-in user.",
"adminConsentDisplayName": "AppName",
"id": "xxx",
"isEnabled": 是的,
"origin": "Application",
"type": "User",
"userConsentDescription": "Allow the application to access AppName on your behalf.",
"userConsentDisplayName": "AppName",
"value": "user_impersonation"
}
该应用程序请求 (OneDrive For Business) 用户登录 Office365 以获取授权码(发送到注册的重定向 URL)并使用它来检索访问令牌(通过 POST 到我的应用程序的令牌端点)。返回的 JWT 中的 "aud" 字段设置为我的客户端 ID。对于 SharePoint Online,它应该是“00000003-0000-0ff1-ce00-000000000000”之类的东西吗?
当我尝试在 https://{tenant}-my.sharepoint.com/_api/v1.0/me/ 上使用访问令牌作为承载在 header 的请求,我收到错误 401:"error: invalid client"、"error: invalid audience URI:https://{tenant}-my.sharepoint.com/"。这指出某处存在配置错误,但我不知道需要更改什么。
aud = 令牌的受众。当令牌颁发给客户端应用程序时,受众是客户端的client_id。您可能想尝试使用发现服务 API 来检查您的服务端点 (https://msdn.microsoft.com/en-us/office/office365/howto/discover-service-endpoints)。错误显示受众 URI 无效,因此您正在调用的 URL 上的服务可能不是 运行(即 https://{tenant}-my.sharepoint。 com/_api/v1.0/我/)。按照上面的 link 应该可以帮助您隔离问题。希望对您有所帮助。
我的目标是编写一些代码,使 Office 365 用户能够通过 REST API 访问 OneDrive for Business 中的文件。我已经在 Azure AD(Web App/multi 租户)中注册了一个应用程序并添加了在线访问 SharePoint 的权限。我想使用 "delegated user identity with OAuth" 场景,我的应用程序使用用户模拟通过 REST APIs 访问 OneDrive for Business。
应用清单中的权限如下:
"oauth2Permissions": [ { "adminConsentDescription": "Allow the application to access AppName on behalf of the signed-in user.", "adminConsentDisplayName": "AppName", "id": "xxx", "isEnabled": 是的, "origin": "Application", "type": "User", "userConsentDescription": "Allow the application to access AppName on your behalf.", "userConsentDisplayName": "AppName", "value": "user_impersonation" }
该应用程序请求 (OneDrive For Business) 用户登录 Office365 以获取授权码(发送到注册的重定向 URL)并使用它来检索访问令牌(通过 POST 到我的应用程序的令牌端点)。返回的 JWT 中的 "aud" 字段设置为我的客户端 ID。对于 SharePoint Online,它应该是“00000003-0000-0ff1-ce00-000000000000”之类的东西吗?
当我尝试在 https://{tenant}-my.sharepoint.com/_api/v1.0/me/ 上使用访问令牌作为承载在 header 的请求,我收到错误 401:"error: invalid client"、"error: invalid audience URI:https://{tenant}-my.sharepoint.com/"。这指出某处存在配置错误,但我不知道需要更改什么。
aud = 令牌的受众。当令牌颁发给客户端应用程序时,受众是客户端的client_id。您可能想尝试使用发现服务 API 来检查您的服务端点 (https://msdn.microsoft.com/en-us/office/office365/howto/discover-service-endpoints)。错误显示受众 URI 无效,因此您正在调用的 URL 上的服务可能不是 运行(即 https://{tenant}-my.sharepoint。 com/_api/v1.0/我/)。按照上面的 link 应该可以帮助您隔离问题。希望对您有所帮助。