Ask A Question


You’re not receiving notifications from this thread.

JWT with Devise (App and API)

Stephen asked in Rails


I'm looking to extend my Rails 5.2 application that uses Devise for authentication so I can support API requests via JSON. I have looked at Chris' videos and did some searching around -- most tutorials I have found only make use of using an "API Only" mode. I would like to make use off of the existing code I have (e.g. use respond_to in the controller, instead of making separate API::Controllers for the exact same code).

Is this possible to do? If so please point me in the right direction. Thank you!


Hey Stephen, did you see the series on how to build an OAuth Provider in Rails? It integrates with Devise, it will generate JWTs for access tokens if you want, and you can use it with iOS and Android to provide a "Login with My App" process just like Twitter or Facebook which is cool.


Hi Chris just wondering if the techinques outlined in the course you've suggested covers using devise for session based login on web alongside OAuth for authenticating the same user over an api for something like a react native app?


Oliver, yep. If you login on the web, you'll login with a session cookie. Otherwise you'll hit the API with a token and be logged in only for that request.

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 84,111+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.