I am trying to access my Azure app registered in Azure Active Directory(AAD). I am using the OAuth2.O Client credential protocol (https://dev.loganalytics.io/documentation/Authorization/OAuth2).
Using the Rest client (Postman) I am able to connect. But I need to do the same in my Java application.
There are 2 steps in connection
To get the access-token.
POST https://login.microsoftonline.com/YOUR_AAD_TENANT/oauth2/token Content-Type: application/x-www-form-urlencoded grant_type=client_credentials &client_id=YOUR_CLIENT_ID &redirect_uri=YOUR_REDIRECT_URI &resource=https://management.azure.com/ &client_secret=YOUR_CLIENT_SECRET
To make a request to the workspace using the access token
POST https://api.loganalytics.io/v1/workspaces/8fXXXXX-0a84-XXX-XXX- c1a5XXXXXX/query?timespan=P1D Authorization: Bearer [access_token] { "query": "AzureActivity | limit 10" }
Can someone help me to write a java client to do above? I referred to the following links:
But they do not use the Tenant id and grant type not client_credentials
.