Try to get access token from serverless

Hi guys,

We need to send an access token via third party node package(Eg: axios, request) for to make an API call.

Already you have said that the way of how to make an API call in the serverless app using access token like:

var options = {
headers: {
Authorization: “bearer<%= access_token %>”
isOAuth: true

$, options)

Yeah that is fine!.

Now we need to send with attachment for to make a API call.

We were know how to send an attachment for the API using third party node package.

The problem is:

Lets say If now we proceed to send an attachment followed by the way, here we need access token to call API.

Third party node package does not read access token when we wrote like <%= access_token %>.

Now how we can to resolve this.

Thank you.

@Karuppu_Samy ,
It is not possible to use the template compiler outside of platform feature such as request API.
if you want to use third party package, then you need to pass the actual value in the request.

Hope it helps :slight_smile:



Yes right we should give an exact value when we call API using third party package.

We were now using oauth.

How we can get exact value of access token which is stored in local automcatically when installation is done by using oauth.

How to access exact access_token value from serverless.

@Karuppu_Samy ,
so, you are trying to invoke an SMI call from the installation page, or on the app setup events, you are trying to get the access_token? can you please clarify?
but why can’t you use the request API to solve your case or is there any blocker to use the request API?


We should send with attachments when make API call using Access Token.

Without OAuth: We can able to send attachment using third party package.

If OAuth: You said, the third party package does not support template

Can you refer this below link,

could you find out the reason why we moved to third party package.

Could you help us to resolve this issue.

How can send attachment with OAuth access token using API call,

Thank you.

Hi @Karuppu_Samy ,
It is not possible with the straightforward approach,
but there is a workaround that you can use the middleware to solve your use case,

step 1:
on app setup events (on Install) → you need to pass the Access token via request API with template literal to the middleware, and store the access token and generate webhook and pass it to middleware

step 2:
use your third party package to call the middleware and attach the access token from middleware and pass it to your backend

step 3:
if the token is expired, use the external events to make any API to refresh the access token and pass it in your middleware

another alternative which I suggest:
use API token instead of Oauth.

Hope it helps :slight_smile:


Thanks for the response.

We will try.

1 Like

Hi @Santhosh ,

We were get access token via middleware and using to call API’s , It is working fine for un till that token has expired.

After the token expiration time has reached. it did not work when we try to call API.

For the every API call before need access token which is refreshed by framework and updated in the local db as it is secured.

@Karuppu_Samy ,
Good Day!

have you tried the step 3 ?

I think this will solve your usecase :slight_smile:


Just to add on to Santhosh,

When the middleware realizes that API call has failed:

  1. Make an API call to webhook that’s generated using external events
  2. The execution context of onExternalEvent should make a request to 3rd party. Since this time the access token fails, the platform will refresh it.
  3. Retry making the same request or platform will automatically retry with the new access token. The request should ideally succeed in confirming that the access token is refreshed.
  4. In the same execution context make an API call to middleware with the access token.
  5. This time middleware can make an API call to 3rd party with an attachment on it.
1 Like

Sorry for the delay response.

We get access token using middleware.


This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.