Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3655

Should I put a user id in a REST url or get it from authentication

$
0
0

I'm building a RESTful api with Express.js. Let's say I have some Users which own Resources. A good way to get the Resources of a specific User would be: GET /users/:user_id/resources.

I implemented authentication for the api and can thus get the user_id from req.user.user_id instead of from the url. This means I could just use GET /resources to get the resources from the authenticated user.

My question: is this good practice and why (or why not)?


Viewing all articles
Browse latest Browse all 3655

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>