Re: Getting expired token

Anonymous
Not applicable

Getting expired token

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.

Tags (1)
7 REPLIES 7
Josh_Hill13
Level 10 - Champion Alumni

Re: Getting expired token

Check developers.marketo.com or ask Support.

Anonymous
Not applicable

Re: Getting expired token

Support link is how i got here.

SanfordWhiteman
Level 10 - Community Moderator

Re: Getting expired token

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?

Anonymous
Not applicable

Re: Getting expired token

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.

SanfordWhiteman
Level 10 - Community Moderator

Re: Getting expired token

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.

Anonymous
Not applicable

Re: Getting expired token

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.

harsh_rohilla
Level 1

Re: Getting expired 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.