0

We are working on a custom connector for Power Apps. This connector basically uses post, get, patch, delete methods of the Dynamics Rest API. For authentication, we are using AAD as mentioned.

We are writing swagger JSON and uploading the file to create/update the custom connector, after which we have to provide CRM URL, Client ID, and Client Secret.

Everything was working smoothly until the custom connector started throwing error that the authorization token has expired.

{
  "status": 400,
  "source": "https://unitedstates-002.token.azure-apim.net:443/tokens/unitedstates-002/-5Ftest-20final-5Fc8793734b9d234d8-5F1ae6317311eb737e/a6bf39bb183d4f89870ba39642194dbe/exchange",
  "message": "Error from token exchange: Bad authorization token. The access token has expired."
}

This error went away after we recreated the custom connector using the same swagger JSON without any change.

How can we avoid this error without needing to recreate the connector every time? Is there anything we are missing regarding to AD Tokens?

Pratik Bhavsar
  • 808
  • 8
  • 32

1 Answers1

0

You can set the token lifetimes as per the documentation.

Please see here for more information:

Configurable token lifetimes in Azure Active Directory

Edit: This is apparently being deprecated May 1, 2020, but you should call for a refresh token if the token you currently have has expired.

Patrick
  • 5,526
  • 14
  • 64
  • 101
  • I already went through that link. My question is, technically, the token should be refreshed every time we call the API, why is it using the same old token. Any way we cab overcome it? – Pratik Bhavsar Feb 01 '20 at 13:18