salezica
salezica

Reputation: 76949

Django: OAuth token storage and renewal

I'm running a Django app that needs to interact with an external API to make requests in behalf of its users.

Before making any calls, I have to obtain an access token through an OAuth-like interface. This token is mine, my users won't have one each. I have tested the entry points and methods with curl, and everything seems to work fine, so I'm ready to integrate the service.

How should I go about requesting, storing, reusing and renewing this token when it expires? Also, which parts of the process should run on the client's browser, and which parts on the Django backend?

Upvotes: 1

Views: 427

Answers (1)

salezica
salezica

Reputation: 76949

I ended up creating a table with a single row, updated to contain the latest valid token.

Main reason: I know that wherever I deploy this application, and no matter how many processes across how many machines are serving, the database will work as storage. It's not that much extra code either, and goes well with Django's application packaging.

Upvotes: 1

Related Questions