SharePoint onprem Rest API calls From Java Application -
getting unauthorized exception, while trying access sharepoint rest apis post requests java web application.as per msdn, formdigest mandatory post requests.how consume sharepoint rest apis non-microsoft applications?
i recommend reading post post sharepoint 2013 java. credentials, have used ntlm (windows) authentication so:
registry<authschemeprovider> authschemeregistry = registrybuilder.<authschemeprovider>create() .register(authschemes.ntlm, new jcifsntlmschemefactory()) .register(authschemes.basic, new basicschemefactory()) .register(authschemes.digest, new digestschemefactory()) .register(authschemes.spnego, new spnegoschemefactory()) .register(authschemes.kerberos, new kerberosschemefactory()) .build(); closeablehttpclient httpclient = httpclients.custom() .setdefaultauthschemeregistry(authschemeregistry) .build(); ntcredentials creds = new ntcredentials(user, password, workstation, domain); credentialsprovider credsprovider = new basiccredentialsprovider(); credsprovider.setcredentials(authscope.any, creds); httpclientcontext context = httpclientcontext.create(); context.setcredentialsprovider(credsprovider);
Comments
Post a Comment