All threads / JWT with Devise (App and API)

Ask A Question

Notifications

You’re not receiving notifications from this thread.

JWT with Devise (App and API)

Stephen Gold asked in Rails

Hi,

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

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

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

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

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.