Secrets/access token

Hi!

I have a service that runs every night at 3 am. It calls an authentication endpoint and saves the accessToken as a secret and then uses that accessToken to call different endpoints. I get no errors on this schedule.

In the solution, I have a button that calls an endpoint in the same API, so I want it to use the accessToken that is stored as a secret. But when I do it, I receive 403 error.

Why can that be?

Some more info:

  • The accessToken is valid for 24 hours.
  • When I use Postman to call the same authentication endpoint and copy that accessToken directly into the secret, the button in the solution works, I get to call the endpoint.
  • The access token that I find in Appfarm, does not work for any endpoint in Postman (403).
  • I see that the secret value for the Production environment is updated every day.

Hi Siri,

It’s hard to say for sure what’s causing the breakdown without seeing the logs, but there might be a few things worth double-checking:

First, if this secret is environment-specific, is it possible the sync is failing for certain environments? I’d check if the nightly updates are actually hitting all environments, or if the dev/test secrets might just be outdated.

Another thought: if the secret works for the scheduled task but fails when you click the button, we might be looking at an encoding or formatting issue. A way to test this is to log the string length of the secret in both scenarios (schedule and the button action). If the lengths don’t match, there’s probably a hidden character or a formatting issue creeping in during the retrieval.

You could also try manually triggering the schedule and hitting the button immediately after. That should tell us if the token itself is valid and help narrow the problem down to how it’s being stored or fetched.

Remember to also double check that you have the correct permission to actually access the endpoint.

And lastly, could you log the schedule in devtools by enabling capture and send the error message to me? (You can send it through DM if that works for you).

Hope this helps!

// Synne