Bearer Tokens in REST API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2024 01:03 AM
Hi everyone, I am currently working on an integration using a REST API that requires a bearer token in the authorization header. The token expires every hour, so I've implemented a POST request to obtain a new token when needed, and then I pass it to the subsequent GET method. I would like to inquire if this approach is correct or if there is a better way? Additionally, how can i pass values securely in the POST method without exposing them ? I am implementing all of this in a flow designer action. Any insights or best practices would be greatly appreciated.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2024 04:02 AM - edited ‎02-08-2024 04:07 AM
Hey @yoli, regarding your approach for getting the token, i think its pretty good. I always use this method and it works fine. When it comes to the values in POST, what i would do is store the credentials inside a system property, and call the property within the POST request. You can also create a protected system property to handle this.
Additionally, and theres the chance you are already doing it, i would call the GET method first, and within the GET function, call the POST method. Something linke below:
//GET Funtion starts
var token = this.getToken() // this would be your function containing the POST method. there you should return the handled token
again, you may be already doing it, but always good to talk about this kind of content. Thanks!
have a great day!