{"action":"closed","issue":{"url":"https://api.github.com/repos/Azure/azure-k8s-metrics-adapter/issues/22","repository_url":"https://api.github.com/repos/Azure/azure-k8s-metrics-adapter","labels_url":"https://api.github.com/repos/Azure/azure-k8s-metrics-adapter/issues/22/labels{/name}","comments_url":"https://api.github.com/repos/Azure/azure-k8s-metrics-adapter/issues/22/comments","events_url":"https://api.github.com/repos/Azure/azure-k8s-metrics-adapter/issues/22/events","html_url":"https://github.com/Azure/azure-k8s-metrics-adapter/issues/22","id":353466560,"node_id":"MDU6SXNzdWUzNTM0NjY1NjA=","number":22,"title":"Add support for GO SDK access to the App Insights via Service Principal","user":{"login":"jsturtevant","id":648372,"node_id":"MDQ6VXNlcjY0ODM3Mg==","avatar_url":"https://avatars0.githubusercontent.com/u/648372?v=4","gravatar_id":"","url":"https://api.github.com/users/jsturtevant","html_url":"https://github.com/jsturtevant","followers_url":"https://api.github.com/users/jsturtevant/followers","following_url":"https://api.github.com/users/jsturtevant/following{/other_user}","gists_url":"https://api.github.com/users/jsturtevant/gists{/gist_id}","starred_url":"https://api.github.com/users/jsturtevant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsturtevant/subscriptions","organizations_url":"https://api.github.com/users/jsturtevant/orgs","repos_url":"https://api.github.com/users/jsturtevant/repos","events_url":"https://api.github.com/users/jsturtevant/events{/privacy}","received_events_url":"https://api.github.com/users/jsturtevant/received_events","type":"User","site_admin":false},"labels":[{"id":1011620488,"node_id":"MDU6TGFiZWwxMDExNjIwNDg4","url":"https://api.github.com/repos/Azure/azure-k8s-metrics-adapter/labels/docs","name":"docs","color":"1d76db","default":false},{"id":1002411506,"node_id":"MDU6TGFiZWwxMDAyNDExNTA2","url":"https://api.github.com/repos/Azure/azure-k8s-metrics-adapter/labels/enhancement","name":"enhancement","color":"a2eeef","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-23T16:49:52Z","updated_at":"2018-09-28T17:50:45Z","closed_at":"2018-09-28T17:50:45Z","author_association":"CONTRIBUTOR","body":"Currently, we access AppInsights with a token,  which limits us to only working with a single application insights instance.  It also requires additional configuration of secrets.  It would be better to use the existing Service Principal that is configured and add appropriate permissions.  I tried this according to the [docs in AppInisghts](https://dev.applicationinsights.io/documentation/Authorization/AAD-Application-Setup) but I am getting 401.  This may just require documenting the correct configuration for the SP.  \r\n\r\n## Additional information\r\n\r\nI am using the [GoMetrics client](https://godoc.org/github.com/Azure/azure-sdk-for-go/services/appinsights/v1/insights#MetricsClient) to access the [App Insights API](https://dev.applicationinsights.io/). I set up the [Azure Authentication for a service principal](https://dev.applicationinsights.io/documentation/Authorization/AAD-Application-Setup) as defined in the docs but I receive the following 403 error message:\r\n \r\n```\r\nbad request: insights.MetricsClient#Get: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: Service returned an error. Status=403 Code='InsufficientAccessError' Message='The provided credentials have insufficient access to perform the requested operation' InnerError={'code':'InvalidTokenError','message':'Could not validate the request. Challenge failed: SignatureVerificationFailed'} \r\n```\r\n \r\nAt first glance in the code everything seems to be correct with the [authorization code  gets the token](https://github.com/Azure/go-autorest/blob/master/autorest/azure/auth/auth.go#L308:36) from the AADEndpoint and that seems to align with the [docs on auth endpoints](https://dev.applicationinsights.io/documentation/Authorization/AAD-OAuth2-Flows). \r\n\r\n "}}
{"actor":{"display_login":"jsturtevant"}}