Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6376637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:46:14+00:00 2026-05-25T01:46:14+00:00

When designing REST API is it common to authenticate a user first? The typical

  • 0

When designing REST API is it common to authenticate a user first?

The typical use case I am looking for is:

  • User wants to get data. Sure cool we like to share! Get a public API key and read away!
  • User wants to store/update data… woah wait up! who are you, can you do this?

I would like to build it once and allow say a web-app, an android application or an iPhone application to use it.

A REST API appears to be a logical choice with requirements like this

To illustrate my question I’ll use a simple example.

I have an item in a database, which has a rating attribute (integer 1 to 5).

If I understand REST correctly I would implement a GET request using the language of my choice that returns csv, xml or json like this:

http://example.com/product/getrating/{id}/

Say we pick JSON we return:

{
  "id": "1",
  "name": "widget1",
  "attributes": { "rating": {"type":"int", "value":4} }
}

This is fine for public facing APIs. I get that part.

Where I have tons of question is how do I combine this with a security model? I’m used to web-app security where I have a session state identifying my user at all time so I can control what they can do no matter what they decide to send me. As I understand it this isn’t RESTful so would be a bad solution in this case.

I’ll try to use another example using the same item/rating.

If user “JOE” wants to add a rating to an item

This could be done using:

http://example.com/product/addrating/{id}/{givenRating}/

At this point I want to store the data saying that “JOE” gave product {id} a rating of {givenRating}.

Question: How do I know the request came from “JOE” and not “BOB”.

Furthermore, what if it was for more sensible data like a user’s phone number?

What I’ve got so far is:

1) Use the built-in feature of HTTP to authenticate at every request, either plain HTTP or HTTPS.

This means that every request now take the form of:

https://joe:joepassword@example.com/product/addrating/{id}/{givenRating}/

2) Use an approach like Amazon’s S3 with private and public key: http://www.thebuzzmedia.com/designing-a-secure-rest-api-without-oauth-authentication/

3) Use a cookie anyway and break the stateless part of REST.

The second approach appears better to me, but I am left wondering do I really have to re-invent this whole thing? Hashing, storing, generating the keys, etc all by myself?

This sounds a lot like using session in a typical web application and rewriting the entire stack yourself, which usually to me mean “You’re doing it wrong” especially when dealing with security.

EDIT: I guess I should have mentioned OAuth as well.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:46:15+00:00Added an answer on May 25, 2026 at 1:46 am

    Edit 5 years later

    Use OAuth2!

    Previous version

    No, there is absolutely no need to use a cookie. It’s not half as secure as HTTP Digest, OAuth or Amazon’s AWS (which is not hard to copy).

    The way you should look at a cookie is that it’s an authentication token as much as Basic/Digest/OAuth/whichever would be, but less appropriate.

    However, I don’t feel using a cookie goes against RESTful principles per se, as long as the contents of the session cookie does not influence the contents of the resource you’re returning from the server.

    Cookies are evil, stop using them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am designing a REST API for a web application. I want to clearly
I am designing a REST API and I wonder what the recommended way to
I am designing a REST API where some resources can be filtered through query
I am designing a REST api for one of my applications & considering using
We are currently designing a REST API that we want to publish in a
I'm working on designing a REST API that can respond with a variety of
I'm designing a REST API. The part I'm working on now involves simply reading
I am designing a rails rest API that I would like to expose either
I'm implementing an API using authentication based on this article: http://www.thebuzzmedia.com/designing-a-secure-rest-api-without-oauth-authentication/ And this related
I'm designing a web service that serves up JSON through a REST API. This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.