I have an application that I tested out with a self-created SharepointServer based on an Active Directory environment. For this I used the following code to authenticate with the Sharepoint server(which worked)

    public void authenticate() {
    Authenticator.setDefault (new Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                logger.info("Authenticated with user: " + user + " and password: " + password);
                return new PasswordAuthentication (user, password.toCharArray());

Now however, they have given me access to an Office 365 environment with a Sharepoint site containing multiple files that have to be read through the API. They have given me a login and a password through which I can log on to the site and check to contents but I am not able to connect to this API (403 error). I have tried the


as a header but also without success. Is there a way I can get my java program authenticated with this online sevice?

1 Answer 1


Google's Google Search Appliance is open sourced so you can use it as a nice working example of Office 365 authentication. See: https://github.com/googlegsa/sharepoint/blob/master/src/com/google/enterprise/adaptor/sharepoint/LiveAuthenticationHandshakeManager.java

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.