Best answer

How to read a value from Basic Auth response and use it in trigger?

  • 8 April 2020
  • 4 replies
  • 1882 views

Userlevel 1

Hi,

My application returns a token in the Basic Auth response. I have to pass that token in trigger polling request. How can I achieve this?

 

Thanks

Srinivas

icon

Best answer by ikbelkirasan 8 April 2020, 18:35

@srinivas.panyala - Yes, Session auth is also available in the UI. You can use it to achieve what you want, but you’ll have to calculate the basic authorization header yourself. Make sure you add the username and password input fields, and in the Step 2: Configure a Token Exchange Request, switch to code mode, add some logic to calculate the token which is the base64 of the username:password combination and set it in the Authorization header in the format: “basic <token>”. And make sure to return an object that contains the token that you would receive from the API. It will be stored in bundle.authData which can be retrieved when you make future requests from a trigger or an action.

View original

This topic has been closed for comments

4 replies

Userlevel 7
Badge +11

Hi @srinivas.panyala - Basic Auth doesn’t requires another token to authenticate except for the base64 of `${username}:${password}`. So maybe you should use “Custom” or “Session” auth instead so you can have more control over what is stored in bundle.authData. Any object that you return from the perform method of the auth type you choose, will be saved in bundle.authData. So in future requests, you can look for that token in bundle.authData before sending the request. I hope this answers your question.

Userlevel 1

Thank you so much for your response. I agree “Basic Auth doesn’t require another token to authenticate except for the base64 of `${username}:${password}`”. My question is about the Basic Auth response. Is there any way to save Basic Auth response in a variable and use that variable in Trigger polling request? I am not using CLI.

Thanks

Srinivas  

Userlevel 7
Badge +11

@srinivas.panyala - Yes, Session auth is also available in the UI. You can use it to achieve what you want, but you’ll have to calculate the basic authorization header yourself. Make sure you add the username and password input fields, and in the Step 2: Configure a Token Exchange Request, switch to code mode, add some logic to calculate the token which is the base64 of the username:password combination and set it in the Authorization header in the format: “basic <token>”. And make sure to return an object that contains the token that you would receive from the API. It will be stored in bundle.authData which can be retrieved when you make future requests from a trigger or an action.

Userlevel 1

Thank you so much. I will follow this approach.