Skip to content

An interceptor for use in Spring Java applications that will intercept rest calls to sharepoint and handle authentication. This is useful for applications that run behind the scenes and do not have a user logged in.

License

Notifications You must be signed in to change notification settings

jonathanhughes/SpringSharepointInterceptor

Repository files navigation

This is a simple spring interceptor that can be added to a rest template for automatically handling authentication with sharepoint when accessing their rest API.

To use: Build the project with gradle. Add the jar to your build path and then define spring beans like so:

@Bean 
public SharepointInterceptor sharepointInterceptor() {
	SharepointInterceptor sharepointInterceptor = new SharepointInterceptor();
	
	sharepointInterceptor.setAuthUrl("https://login.microsoftonline.com/extSTS.srf");
	sharepointInterceptor.setSiteUrl("https://yourcompany.sharepoint.com/");
	sharepointInterceptor.setAccessTokenUrl("https://yourcompany.sharepoint.com/_forms/default.aspx?wa=wsignin1.0");
	sharepointInterceptor.setDigestUrl("https://yourcompany.sharepoint.com/_api/contextinfo");
	sharepointInterceptor.setUser("[email protected]");
	sharepointInterceptor.setPassword("yourpassword");
	
	return sharepointInterceptor;
	
}

@Bean
public RestTemplate restTemplate() {
	RestTemplate restTemplate = new RestTemplate();

	List<ClientHttpRequestInterceptor> interceptors = new ArrayList<>();
	interceptors.add(sharepointInterceptor());
	
	restTemplate.setInterceptors(interceptors);
	
	return restTemplate;
}

About

An interceptor for use in Spring Java applications that will intercept rest calls to sharepoint and handle authentication. This is useful for applications that run behind the scenes and do not have a user logged in.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages