How can I develop an App using Make Apps SDK (integromat.com) that:
- Set a token (used in Header) and the expiration date
- After reaches the expiration date, it gets a new token and set the new expiration
I tried this example for the Communication (api.imljson
)
{
"token": {
"url": "https://example.com/credential/generate_token",
"method": "POST",
"body": {
"email": "example@example.com.br",
"publickey": "example-public-key",
"apikey": "example-public-key"
},
"type": "urlencoded",
"response": {
"data": {
"expires": "{{ parseDate(body.data.token_valid_until, 'YYYY-MM-DD HH:mm:ss', environment.timezone) }}",
"token": "{{body.data.token}}"
}
},
"log": {
/**
"sanitize": [
"request.body.email",
"request.body.publickey",
"response.body.token"
]
*/
}
},
"refresh": {
"condition": "{{data.expires < addMinutes(now, 1)}}",
"url": "https://example/credential/generate_token",
"method": "POST",
"body": {
"email": "example@example.com.br",
"publickey": "example-public-key",
"apikey": "example-public-key"
},
"type": "urlencoded",
"response": {
"data": {
"expires": "{{ parseDate(body.data.token_valid_until, environment.timezone) }}",
"token": "{{body.data.token}}"
}
},
"log": {
/**
"sanitize": [
"request.body.email",
"request.body.publickey",
"response.body.token"
]
*/
}
}
}
The response from POST https://example.com/credential/generate_token
is:
{
"success": true,
"data": {
"token": "eyJhbGciOiJIUzI1NiIsInR55uZWN0dGhpbmsuY29tLmJyIn19.jOKS0mrcg6w+A7L//YdU=",
"token_valid_until": "2022-08-24 20:54:18"
},
"profile": {
"start": 1661381657.959692,
"finish": 1661381658.055,
"process": 0.09530806541442871
}
}