Hi,
I have a number of jobs that connect to marketo to download or upload data via RESTAPI.
each one connects, and geta a session token:
<logsnip>
Token: b181289f-013d-4075-bda4-80a4583071a9:ab and expires in 0
So I added a check for the expiration: and if expired, get a new token.
try 2nd time to get a token: b181289f-013d-4075-bda4-80a4583071a9:ab returned
same expired token returned.
obvious result when using CURL:
{"requestId":"c500#153609e0084","success":false,"errors":[{"code":"602","message":"Access token expired"}]}
Why do i get an expired token, and why do i get the same expired token a 2nd time, even after checking?
This job typically runs in seconds and only grabs a few 100k of data.
Its not always the same job either. it could be the first one of the morning, or the 3rd one, 45 minutes later.
Check developers.marketo.com or ask Support.
Support link is how i got here.
You may be dealing with sub-second granularity, or some other timer-related issue. Marketo should give you the same token back until it expires, but if at least a full second has gone by (from Marketo's perspective) since it expired, it should give you a fresh one.
Are you getting a raw JSON response with TTL 0 multiple times in a row, with more than a second in-between?
im checking for the expires = 0 and getting a new token immediately.
i'll add a delay for the 2nd token grab and see if that helps.
Yeah, sleep for a second and let me know. I'm curious if that's what it is. My technique is to rotate 2 API users, which dodges the problem.
I have a check now that looks for a expiresin of less than 5 seconds, and then sleeps for 15. then requests a new token.
Hi, I faced a similar issue. I used to get an 'access token expired' error message from marketo. To fix the issue, we adopted a naive approach of checking if the 'expires-in' for a particular token is less than 10s,then we added a delay of 11s using Javascript setTimeout wrapped in a promise to call the identity endpoint to generate a new token. This will create a new token each time when 'expires-in' for a current time is less than 10s but the catch here is technically my AWS lambda function is taking 11s more for executing which eventually will increase the lambda costing. Please suggest some alternatives to solve this problem. Although each of our operations takes less than 5 sec and token expiring is a rarity. We are dealing with sensitive data here and can't afford this problem.