简体   繁体   English

Sharepoint 在线 REST API 连接

[英]Sharepoint Online REST API connection

I am trying to connect from Java to the Sharepoint Online REST API.我正在尝试从 Java 连接到 Sharepoint 在线 REST ZDB974238714CA8DE63ZF7ACE14

I previously used a SharepointOnline ADD-IN registered directly in the Sharepoint system that has permissions to all the site collections (FullControl).我之前使用了直接在 Sharepoint 系统中注册的 SharepointOnline ADD-IN,该系统具有对所有站点 collections (FullControl) 的权限。 I got the token with the app credentials from the url: https://accounts.accesscontrol.windows.net/ /tokens/OAuth/2 I can make requests to the Sharepoint REST API directly I got the token with the app credentials from the url: https://accounts.accesscontrol.windows.net/ /tokens/OAuth/2 I can make requests to the Sharepoint REST API directly

Now I have to switch to an Azure registered app.现在我必须切换到 Azure 注册的应用程序。 The code is written in Java and I use the Azure sdk-com.microsoft.azure (artifactId-azure).代码写在 Java 中,我使用 Azure sdk-com.microsoft.azure (artifactId-azure)。 I can successfully retrieve a token, but this is not valid for later requests to the Sharepoint REST API.我可以成功检索令牌,但这对于以后对 Sharepoint REST API 的请求无效。

I get this error: 'Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException' was thrown."我收到此错误:引发了“Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException”。”

Is there any possibility to get a valid token for Sharepoint REST API requests?是否有可能为 Sharepoint REST API 请求获取有效令牌?

Have you looked at Microsoft Graph API.你看过 Microsoft Graph API。 Check it.核实。 It provides all the options for authentication and authorization.它提供了身份验证和授权的所有选项。 Also the rest API calls are technology agnostic.此外,rest API 调用与技术无关。

Yes this is possible.是的,这是可能的。 Check out the below document:查看以下文档:

https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azuread https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azuread

When using SharePoint Online you can define applications in Azure AD and these applications can be granted permissions to SharePoint, but also to all the other services in Office 365. This model is the preferred model in case you're using SharePoint Online, if you're using SharePoint on-premises you have to use the SharePoint Only model via based Azure ACS as described in here. When using SharePoint Online you can define applications in Azure AD and these applications can be granted permissions to SharePoint, but also to all the other services in Office 365. This model is the preferred model in case you're using SharePoint Online, if you' re using SharePoint on-premises you have to use the SharePoint Only model via based Azure ACS as described in here.

Hope this helps!希望这可以帮助!

You can take a look of this project i've develop (and i'm currently working on it on my free time) where you have a working implementation of a java API to communicate with sharepoint rest api v1 and perfom common operations (rest api is still not fully covered but has most common operations and also provides a starting point with working examples). You can take a look of this project i've develop (and i'm currently working on it on my free time) where you have a working implementation of a java API to communicate with sharepoint rest api v1 and perfom common operations (rest api仍未完全涵盖,但具有最常见的操作,并且还提供了工作示例的起点)。 You can take a look of it at你可以看看它

https://github.com/kikovalle/PLGSharepointRestAPI-java https://github.com/kikovalle/PLGSharepointRestAPI-java

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM