Marko vlaić
Marko vlaić

Reputation: 316

Node js - Best practice for authorizating RESTFUL API requests

So I am creating a REST API that will do database queries and send data for my android app in node js. However I want to use some kind of authorization when doing these requersts. Which methods could I use to do this stuff? Thanks in advance :)

Upvotes: 0

Views: 124

Answers (2)

hankchiutw
hankchiutw

Reputation: 1662

I suggest using passport.

It supports many common authentication strategies, including http bearer, google, facebook, etc. You can also define your own strategy. Have a try!

Upvotes: 1

cyberwombat
cyberwombat

Reputation: 40084

There are a few option but I would look at JWT token authentication for this. You'd have the user enter something like a username/pass in the android app then send this securely to your server which will return a token of whatever duration you desire. That token is then sent for every api request - usually in the headers.

Google "Node auth jwt token" and you should get some articles such as this.

Upvotes: 1

Related Questions