Skip to main content

Token Auth API with Devise

Gems / Libraries • Asked by Michael Stitt

I just watched your screencast on using Devise for user authentication and learned quite a bit. However, I not only want to create a web app but I'd also like to provide a JSON API as another way to interact with the database. Do you think you could create a screencast where you show us how to go about doing something like this? I read through the comments and it looks like other people are looking for something similar.

I found an open-sourced app but I'd love to hear you walk us through why you're choosing to do different things.

I love your screencasts, keep pumping 'em out!


That app is pretty good and I've used Devise token_authenticatable in the past and it works pretty well. I'd recommend using as long as you don't need something complicated with your API tokens.

I think doing an episode on using token_authenticatable and one from scratch would be great. Are there any particular things you'd like to see covered in an episode?


I guess I'd just like to hear you point out any long-term considerations we should take into account when attempting to build API endpoints, as well as a web interface in the same Rails app.

I've read that it's advantageous to store API tokens in a Redis instance, is that feasible when using Devise?

I've never built a production-facing API so any advice/guidance would be much appreciated!


Here's a first episode on the topic! :) https://gorails.com/episodes/api-tokens-with-devise-token-authenticatable

API tokens in Redis would be useful for accessing them very quickly without hitting the database. Performance would be the primary reason here and you could also have them autoexpire using the built in Redis expiration functionality


Awesome! I'm looking forward to watching this when I get home.

Keep up the good work!


This was great, Chris! Keep up the good work!



Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.