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)
6 REPLIES 6
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.