How is your experience with the OutSystems Community?
21
Views
3
Comments
How to create access token to be used in REST API dynamically?
Question
Application Type
Mobile

Hi i am wondering whether we can create bearer token dynamically?

thank you

2026-03-03 06-24-34
Grijesh Suman

Hi @IQ78 ,


You can send something like this in Teams: For dynamic token generation, create a separate GetAccessToken API. This API will generate the access token using the client credentials, save the token in the database along with its expiry date/time, and return the existing token if it's still valid. Before each REST API call, check the token expiry; if expired, generate a new token and update the DB. Then use the token in the Authorization: Bearer {token} header for subsequent API calls. 

2026-05-21 04-48-12
Deepa Tiwari

Hi @IQ78 ,

Yes, you can create a Bearer token dynamically. We implemented a similar approach in one of our projects.

Our implementation works like this:

  1. We created a separate Generate Token API.
  2. The consumer system calls this API using an API Key and API Secret.
  3. After validating the credentials, we generate a JWT Bearer Token.
  4. The generated token is stored in the database along with its expiry time (in our case, 30 minutes).
  5. The consumer system then uses this token when calling the actual API, for example:

Authorization: Bearer 

  1. On the target API, we validate:
    • API Key
    • Bearer Token
    • Token expiry
    • JWT validity/signature

If all validations pass, the request is processed; otherwise, the API returns an unauthorized/failed response.

So the overall flow is:

1. Consumer System   
      API Key + API Secret
2.Generate Token API 
     Generate JWT 
3.Bearer Token (30 min expiry) 
      Authorization: Bearer   
4.Protected API  
     Validate Token + API Key   
5.Pass Success / Failure

This approach worked well for us when we needed dynamic, short-lived authentication tokens between systems.

Regards
Deepa

2026-01-28 16-57-48
Mihai Melencu
Champion
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.