Skip to main content

Hi, I need to create a custom authorization, the first step is to request a Bearer token using an API key, and then use this token in the headers for all the requests, I’m using a session auth type, and everything is working fine, but the token needs to be refreshed, so, after some time the connection fails since the token is not valid anymore, how can I call a refresh of the token? This option is only available in the OAuth2 authorization type, but I don’t need this auth type, so far I have this code, but I can’t figure out how to add the token refresh call and to set up the token session again:
 

module.exports = {
type: 'session',
test: {
headers: { Authorization: 'Bearer {{bundle.authData.token}}' },
url: '{{bundle.authData.base_url}}healthcheck',
},
fields: i
{
computed: false,
key: 'API-KEY',
required: true,
label: 'API Key',
type: 'string',
},
{
computed: true,
key: 'token',
required: false,
type: 'string'
},
],
sessionConfig: {
perform: {
headers: { 'API-KEY': '{{bundle.authData.API-KEY}}' },
method: 'POST',
url: '{{bundle.authData.base_url}}v1/auth/token',
},
},
connectionLabel: getConnectionLabel,
};

 

Be the first to reply!

Reply