5

I'm creating a Rails app which have both a GUI part, and a REST/JSON-API.

The REST/JSON API is fairly simple, and the controller returns data like this:

def get_players
    @players = Player.all
    render json: @players
end

The GUI part of the app is using Devise for authentication, and it works fine.

Now I want to add authentication for the REST/JSON Api too, how do I do that?

Also, how do I test the REST API using curl when the Authentication is added?

---- edit ----

as it turns out, Devise wasnt necessary in this case. A home-cooked token-authentication method works for now. (token created when Player is created, and returned on correct e-mail/password combo).

1 Answer 1

7

After getting a few tips, I found a number of great sites. There are several ways to do this, however I don't know which one is best, but these sites help a long way:

Sign up to request clarification or add additional context in comments.

1 Comment

The labs.kollegorna url is dead, but I found the content here: github.com/kollegorna/labs.kollegorna.se/blob/master/source/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.