use of com.microsoft.graph.authentication.IAuthenticationProvider in project msgraph-sdk-java by microsoftgraph.
the class TestBase method GetAuthenticatedClient.
private void GetAuthenticatedClient() {
if (graphClient == null) {
try {
accessToken = GetAccessToken().replace("\"", "");
IAuthenticationProvider mAuthenticationProvider = new IAuthenticationProvider() {
@Override
public void authenticateRequest(final IHttpRequest request) {
request.addHeader("Authorization", "Bearer " + accessToken);
}
};
IClientConfig mClientConfig = DefaultClientConfig.createWithAuthenticationProvider(mAuthenticationProvider);
graphClient = GraphServiceClient.fromConfig(mClientConfig);
} catch (Exception e) {
throw new Error("Could not create a graph client: " + e.getLocalizedMessage());
}
}
}
use of com.microsoft.graph.authentication.IAuthenticationProvider in project msgraph-sdk-java by microsoftgraph.
the class GraphServiceClientTest method testClientMethodsReturnStuff.
@Test
public void testClientMethodsReturnStuff() {
IGraphServiceClient client = GraphServiceClient.fromConfig(new DefaultClientConfig() {
@Override
public IAuthenticationProvider getAuthenticationProvider() {
return auth;
}
});
assertEquals(auth, client.getAuthenticationProvider());
assertNotNull(client.getExecutors());
assertNotNull(client.getHttpProvider());
assertNotNull(client.getLogger());
assertNotNull(client.getSerializer());
}
use of com.microsoft.graph.authentication.IAuthenticationProvider in project msgraph-sdk-java by microsoftgraph.
the class GraphServiceClientTest method testOverrideOfDefaultAuthenticationProvider.
@Test
public void testOverrideOfDefaultAuthenticationProvider() {
IAuthenticationProvider ap = new IAuthenticationProvider() {
@Override
public void authenticateRequest(IHttpRequest request) {
// do nothing
}
};
IGraphServiceClient client = //
GraphServiceClient.builder().authenticationProvider(//
ap).buildClient();
assertEquals(ap, client.getAuthenticationProvider());
assertNotNull(client.getExecutors());
assertNotNull(client.getHttpProvider());
assertNotNull(client.getLogger());
assertNotNull(client.getSerializer());
assertEquals(ap, ((DefaultHttpProvider) client.getHttpProvider()).getAuthenticationProvider());
}
Aggregations