use of com.azure.identity.InteractiveBrowserCredentialBuilder in project msgraph-sdk-java-core by microsoftgraph.
the class InteractiveBrowserMain method main.
public static void main(String[] args) throws Exception {
final InteractiveBrowserCredential interactiveBrowserCredential = new InteractiveBrowserCredentialBuilder().clientId(CLIENT_ID).redirectUrl("http://localhost:8765").build();
final TokenCredentialAuthProvider tokenCredentialAuthProvider = new TokenCredentialAuthProvider(SCOPES, interactiveBrowserCredential);
final OkHttpClient httpClient = HttpClients.createDefault(tokenCredentialAuthProvider);
final Request request = new Request.Builder().url("https://graph.microsoft.com/v1.0/me/").build();
httpClient.newCall(request).enqueue(new Callback() {
@Override
public void onResponse(Call call, Response response) throws IOException {
System.out.println(response.body().string());
}
@Override
public void onFailure(Call call, IOException e) {
e.printStackTrace();
}
});
}
use of com.azure.identity.InteractiveBrowserCredentialBuilder in project azure-maven-plugins by microsoft.
the class OAuthAccount method createCredential.
protected TokenCredential createCredential(AzureEnvironment env) {
AzureEnvironmentUtils.setupAzureEnvironment(env);
InteractiveBrowserCredentialBuilder builder = new InteractiveBrowserCredentialBuilder();
if (isEnablePersistence()) {
builder.tokenCachePersistenceOptions(new TokenCachePersistenceOptions().setName(TOOLKIT_TOKEN_CACHE_NAME));
}
return builder.redirectUrl("http://localhost:" + FreePortFinder.findFreeLocalPort()).build();
}
Aggregations