Steps to generate a refresh token in D365 BC are described below and follow this sequence.
- Create an authorization request link.
- Request the user for authorization.
- Import the postman collection & generate the refresh token.
Step 1 - Create an authorization request link
To obtain authorization for your app, you must create an authorization request link that you can send to users. The authorization flow begins by redirecting a browser to the authorization request link with a set of query parameters. Replace the below URL with the respective tenant_id, client_id, and client_secret to create the authorization request link.
https://login.windows.net/{tenant_id}/oauth2/authorize?resource=https://api.businesscentral.dynamics.com&client_id={client_id}&client_secret={client_secret}&redirect_uri=https://cleointegration.cloud&response_type=code
To learn more about tenant_id, client_id, and client_secret in D365 BC, refer to this article.
Step 2 - Request the user for authorization
This step of the authorization flow requests the user to authorize your app. If the user is not signed in, the user is redirected to the sign-in page. After signing in, the user is redirected to a page with the authorization code value.
- Open the URL in a browser (incognito mode) with the above authorization request link.
- The code may/may not be available in the URL. However, this value can be fetched using the “Inspect” page. You can inspect the page by right-clicking and selecting the “Inspect” option.
- Sign into the application and this will redirect the user to the redirect_uri provided in your authorization request link.
- Select the “Network” tab on the Inspect page and you can filter with text as “code” in the search bar. This will expand the request URL in the Headers sub-tab & extract the “code” from the Request URL.
Note: The code obtained in this step is short-lived; hence you should proceed to the next step as soon as possible.
Step 3 - Import the postman collection & generate the refresh token
- Import the sample postman collection.
- Select the “Get Access Token” API request and edit the “code” value within the body tab with the new value extracted in the previous step.
- Replace the {tenant_id}, {client_id} and {client_secret} with the valid values and click the send button to get the access_token & refresh_token in the response body.
Comments
0 comments
Please sign in to leave a comment.