I've written a Java app that connects to an On-Premise SharePoint server and does all kinds of stuff.
This app uses SOAP web services and authenticates through NTLM or basic auth.
I migrated to SharePoint Online and the app can no longer connect to it. (it doesn't accept NTLM.
I'm now trying to authenticate to SharePoint Online using Postman extention for Chrome and basic auth and digest auth.
This is the result I get :

<?xml version="1.0" encoding="utf-8"?>
<m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<m:code>-2147024891, System.UnauthorizedAccessException</m:code>
<m:message xml:lang="fr-FR">Access denied. You do not have permission to perform this action or access this resource.</m:message>

I'm using an admin profile that has total control by the way.

So is it possible to authenticate to SharePoint Online using basic or digest authentication ? and if so, how is it done ?
Also, is there a java api that does these things ?

PS : Please don't give any solutions for C# or .Net (they have built in solutions) or for SharePoint On-Premise (as I've allready done that).

  • Do you need user context for your app, or it's ok to use one "elevated" account? Jan 5, 2017 at 9:24
  • Hello @Kai Yes I need user context.
    – Ali
    Jan 5, 2017 at 9:30

2 Answers 2


I don't think it's possible to use digest or basic in Online.
From my perspective, you have different possible solution depending on your requirements.

From my POV there are three options available:

  1. Since you need user context, the easiest way for you is to create Azure AD application and use OAuth in order to obtain access token. You need to get access token for SharePoint resource specifically.
    There is a library for Azure AD and Java - ADAL for Java Sample using active-directory-java-webapp. Basically you need to create new application inside Azure AD, add SharePoint as "permission to other applications".
    Some useful links - Azure Active Directory developer's guide and Integrating applications with Azure Active Directory.
    For start, you can do a POC - create new application in azure ad, add permissions to manipulate sharepoint, use JAVA ADAL to get access token for sharepoint resource, and finally query list title with access token.

  2. Other way is to create SharePoint addin, but I'm not aware about JAVA component making you life simpler when programming SharePoint addins. Basically it also uses OAuth, but there is no authorization code flow, refresh token given you directly via POST request from SharePoint. To implement this approach you need to dig a bit into .NET implementation (SharePointContext.cs)

  3. The last option is to use direct username\password with federated authentication. I'm also not familiar if there is a corresponding library for JAVA, I can only give you an example in nodejs from here. In short, you need to POST preconfigured SAML XML to MS Online Security Token Service (STS), receive encoded token and exchange it to auth cookie with SharePoint Online. You can use a fiddler to see the actual requests.

  • Thanks a lot for the help, I used the last option. It was really hard to do but for anyone who might find this helpful if you're using POST services you have to request a digest token using the cookies. Here's an article that might help article paulryan.com.au/2014/spo-remote-authentication-rest
    – Ali
    Jan 9, 2017 at 16:28

Not sure if this is gonna work for Online... but this should give you some idea https://www.dsouzajoel.com/2015/12/09/connect-to-sharepoint-on-premise-using-external-applications/

  • I just tried it and it did not work. I'm getting 403 forbidden. It's the same error I've had in my previous attempts
    – Ali
    Jan 5, 2017 at 9:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.