Reputation: 285
I am stuck on step 2.4 of this wiki
In the previous step, I get a valid token.
Why do I get "Valid authentication was not provided"?
I added a header called Authorization - see picture.
What am i missing?
Upvotes: 1
Views: 4260
Reputation: 937
I needed to do:
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d 'client_id=<client id>&scope=https://api.loganalytics.io/.default&client_secret=<client secret>&grant_type=client_credentials' 'https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token'
to get this to work, i.e.:
POST /<your tenant id>/oauth2/v2.0/token
Host: login.microsoftonline.com
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials
&client_id=<>
&client_secret=<>
&scope=https://api.loganalytics.io/.default
I hope this helps someone :) It took way too long for me to figure this out lol.
Upvotes: 0
Reputation: 10350
You may also create API key and use it for your request:
x-api-key
Upvotes: 1
Reputation: 23141
When we use Azure Log Analytics REST API to do a query, we need to use Authorization=Bearer eyJ....
as request Headers. For more details, please refer to here.
For example
Register Azure AD application
Give the AAD Application access to our Log Analytics Workspace. Please assign Log Analytics Reader
role to the AD application
Get access token
POST /<your tenant id>/oauth2/token HTTP/1.1
Host: login.microsoftonline.com
Content-Type: application/x-www-form-urlencoded
grant_type =client_credentials
&client_id=<>
&client_secret=<>
&resource=https://westus2.api.loganalytics.io
POST https://api.loganalytics.io/v1/workspaces/{workspaceId}/query
Authorization: Bearer ey...
Content-Type: application/json
{
"query": ""
}
Upvotes: 3