Azure / ms-rest-nodeauth

node.js based authentication library for Azure with type definitions
MIT License
33 stars 33 forks source link

Invalid token generating from service-principal and secret based login method #111

Closed shivaram93 closed 3 years ago

shivaram93 commented 3 years ago

Configured service principal and trying to use the token received from the method to hit customer insights API.

https://api.ci.ai.dynamics.com/v1/instances/{instanceId}/profilestore/stateinfo

Above API requires bearer token as header for authorization.

Token receiving from auth response is invalid and not accepting by Customer Insights API.

msRestNodeAuth.loginWithServicePrincipalSecretWithAuthResponse(clientId, secret, tenantId).then((authres) => { console.dir(authres, { depth: null }) }).catch((err) => { console.log(err); });

error

sadasant commented 3 years ago

@shivaram93 hello! I'm Daniel and I'll be doing my best to help you.

The default authentication assumes you are working against the ARM instances, which are intended to manage, create, delete and update resources. This level of interaction is not specific to a customer instance of any service.

Are you using any Insights package among the ones we offer on NPM?

ms-rest-nodeauth is intended to be used with client libraries that are specific to each service. These libraries generally deal with setting the scope/resource correctly.

If you can send me a bigger snippet, with the client you're using, and some representation of the parameters you're sending, that would be amazing!

With some more context I might be able to provide a better answer.

sadasant commented 3 years ago

@shivaram93

Perhaps even more important, what error are you getting exactly?

sadasant commented 3 years ago

I believe this issue can be resolved by https://github.com/Azure/ms-rest-nodeauth/issues/112, but please correct me if I'm wrong.

sadasant commented 3 years ago

I'll be closing this for the time being. Thank you @shivaram93 for working with our SDKs, and thank you @mjohnst for all of your help with this issue!