How to hold temporary data between API calls/endpoints?

Options
There is an API which for its authentication to get an auth token requires creating a unique random and temporary id which you add to the first request.

It then redirects to the redirect_uri you predefined with 2 query parameters, one of which is the id provided before, and that call needs to verify that it is the same id. 

So i created one call that sets everything up and uses a uuid to create the verification code, then created another endpoint which is the redirect uri where i want to verify that it is the same code i created in the last call being passed back.

So i need to pass the uuid i made to this call which means saving it somewhere. Is there a best practice for saving or passing temporary data? 

I thought to save it to a user table but i won't know the user id until the end of the second call. Should I create a temporary id, or use the uuid as the user id, and at the end change it to the actual username? How would I even pull up the correct user record on the second call?  

Comments

  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options
    Hey ,

    You can follow how this was done for Twitter OAuth. They require a separate table to keep track of a secret between api calls.

    If you want something more temporarily, you could use Data Caching via redis. That lets you store key/value pairs in temporary storage. If the TTL between calls isn't long, then this could be an easy win.
  • Jay
    Jay Member
    Options
     Looks like data caching is on the $200/m plan?
  • Jay
    Jay Member
    Options
    Ok i see how it was done in twitter auth, i can work with that