Pace doesn't refresh token for every 30 minutes

I wanted to make a post call, and i want to refresh token fro every 30 mins, Below is what i tried.

I tried to use pace - to call token method for every 30 mins like this , but pace doesn’t execute for every 30 mins, I was expecting pace to execute once as the method starts and execute next token method only after 30 mins, but it executes even before 30 mins -one after the other as the method starts. (sequential fashion - not periodically)

Is it advisable to use pace -here to refresh the token periodically before executing the actual method?

private def Submit(noOfRuns: Int, bidSlots_feeder: BatchableFeederBuilder[String], round: String): ChainBuilder = {
pause(pauseBy(5) seconds)
.repeat(noOfRuns) {
  pace(3600 seconds) // —> want to run token method to set token in the session for every 30 mins.
  .exec(AuthRequest.auth_token)
  .feed(order_feeder)
  .doIfEqualsOrElse(round, “1”) {
    pause(pauseBy(10) seconds)
    .exec(postToUri(s"${config.base}/orders/#{$AuctionId}/base-order/proxy-order", s"Submit orders for : #{$OrderId}")
       .queryParam(“employeeId”, “#{empNo}”)
       .body(StringBody(session => {
          // body
     })
   )
  )
}

//postToUri uses the access token from the session for the post call.

Token Refresh - Meanwhile I referred the link, and want to refresh token prior to it expires. and want to try out the solution from the link.
Can you please advise the solutions that was implemented below and how token is refreshed here before it expires in the block below?

def setToken: Expression[Session] = session => {
  val accessToken = gettoken();
  session.set(“token”,setToken)
}

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