OAuth2.0 Connection seems to renew on every call

I’m looking for some help to fix a fault in my app connection. I’m creating an app to connect to Guesty which is using OAuth2.0 (client_credentials). I’m allowed to request/renew the Access token max. 5 times a day. It seems as if the app is requesting a new token every time I run a module as I’m now locked for the next 24hrs without a valid Access token (ratelimit). Can someone spot the problem in my connection code?

  • to renew the key I just need to rerun the generate call. So no specific refresh calls.
  • details about the authorization with the API: Authentication

Communication code for the Connection:

{
	"token": {
		"condition": "{{if(data.accessToken, data.expires < addMinutes(now, 1), true)}}",
		"url": "https://open-api.guesty.com/oauth2/token",
		"body": {
			"client_id": "{{parameters.clientId}}",
			"grant_type": "client_credentials",
			"client_secret": "{{parameters.clientSecret}}"
		},
		"type": "urlencoded",
		"method": "POST",
		"response": {
			"data": {
				"expires_in": "{{addSeconds(now, body.expires_in)}}",
				"accessToken": "{{body.access_token}}"
			}
		},
		"log": {
			"sanitize": ["request.body.client_secret", "response.body.access_token"]
		}
	}
}

Thanks for the help!

Hey @WorkNinjas you are missing the expires

Do you mean I should use response.data.expires?

The documentation status that response.expires will force a manual reauth through the connections tab.

P.S. The editor itself created most of the code for client credentials. So the expires_in came from that.

it works with response.data.expires

1 Like