Reputation: 762
I am trying to connect to Microsoft Share Point from my Java application. The documentation for Microsoft Graph SDK for Java is not so clear.
I am trying to initiate the Graph client, while providing the credentials needed via a custom GUI or configuration file.
I am trying to do as follow but can
IGraphServiceClient client = GraphServiceClient.builder().authenticationProvider(authenticationProvider).buildClient();
I need the "authenticationProvider" object to be of a class implementing IAuthenticationProvider, however its not clear what parameters to add or how to create this object. Has anyone tried this before and what is the correct way to build the client and provide the required credentials?
Upvotes: 10
Views: 14250
Reputation: 172
Microsoft has an example project where they have a simple instance of IAuthenticationProvider.
public class SimpleAuthProvider implements IAuthenticationProvider {
private String accessToken = null;
public SimpleAuthProvider(String accessToken) {
this.accessToken = accessToken;
}
@Override
public void authenticateRequest(IHttpRequest request) {
// Add the access token in the Authorization header
request.addHeader("Authorization", "Bearer " + accessToken);
}
}
Upvotes: 6
Reputation: 142094
The AuthenticationProviders that implement a variety of different OAuth flows are available in a seperate package. See this Github repo here:
https://github.com/microsoftgraph/msgraph-sdk-java-auth
Upvotes: 1