GuidoPreite / DRB

Dataverse REST Builder
MIT License
101 stars 14 forks source link

Export as Postman Collection - Grant Type = Client Credentials #1

Closed DynamicsNinja closed 3 years ago

DynamicsNinja commented 3 years ago

It would be cool to have the option to choose which grant type will be used in Postman. Currently, it's exporting it with Grant Type set to Implicit, but when we are using integration user for testing APIs it would really helpful that we have an already generated template for Client Credentials flow.

GuidoPreite commented 3 years ago

If I change inside Postman to "Client Credentials" I see the following properties: image I assume you will provide both "Client ID" and "Client Secret" (for implicit I put 51f81489-12ee-4a9e-aaae-a2591f45987d as default {{clientid}} value) and the "Access Token URL" as well. I can define a new export type with "Client Credentials", is enough to define these 3 attributes as variables with no values or do you think "Access Token URL" should be set to something more useful? (like a prefix or reading from another variable) for example the {{url}} variable contains the url from the instance where the file has been exported. An example of the "Access Token URL" you use in your scenario would be useful. What do you think?

DynamicsNinja commented 3 years ago

There would be great if we have 3 variables:

There is a great blog post that describes the difference between 2 ways of doing it (with the scope and without scope) https://nishantrana.me/2020/12/16/fixed-401-unauthorized-error-while-calling-dynamics-365-web-api/

Case 1

Access token URL without scope: https://login.microsoftonline.com/<TenantId>/oauth2/token (URL without v2)

Case 2

Access token URL if using scope: https://login.microsoftonline.com/<TenantId>/oauth2/v2.0/token Scope: https://<ORGANIZATION>.crm4.dynamics.com/.default

I hope that this information will help you.

GuidoPreite commented 3 years ago

Implemented in version 1.0.0.3