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 7920907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:23:19+00:00 2026-06-03T16:23:19+00:00

In my REST API I would like to use some token based / cookie

  • 0

In my “REST API” I would like to use some token based / cookie based authentication. That means, before the API can be used by consumer the consumer needs to obtain this token by calling some Authentication URL with username/password.

Is it OK to just return a Set-Cookie Header?

I think it actually breaks the REST principle but how would you do it (or design the uris and verbs) without HTTP Basic Auth (which means sending username/pwd in every request)?

Maybe like this?

GET api/authentication/signin/?username=abc&pwd=123
GET api/authentication/signout

or?

GET    api/user/authtoken/?username=abc&pwd=123    (signin)
DELETE api/user/authtoken/     (signout)
GET    api/user/               (returning details of the current user)

What about registration then?

POST    api/user/   (which would also return an authtoken)

or?

GET    api/user/abc/authtoken/?pwd=123    (signin of user abc)
DELETE api/user/abc/authtoken/     (signout)
GET    api/user/abc/               (returning details of user abc)
  • 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-06-03T16:23:21+00:00Added an answer on June 3, 2026 at 4:23 pm

    I would treat a session as a resource:

    POST /sessions
    

    Creates a session and returns a cookie.

    DELETE /sessions/:sessionid
    

    To delete the cookie and log off.

    GET /session/:sessionid
    

    To check if the session is valid (e.g. Cookie didn’t expire or otherwise invalidated).

    But I think you should also implement Basic Auth or some other scheme that’s standard and require a your custom session stuff to be authenticated via it while the rest of the API could also use the session data via the cookie.

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

Sidebar

Related Questions

I would like to generate useful documentation for a REST API written in Python.
I'm developing a REST api. To simplify my question, I have an API that
We have a REST API where clients can supply parameters representing values defined on
I'm developing a REST api which needs to support optional filtering of properties based
I'm building a REST API, but I've encountered a problem. It seems that accepted
I have a REST api which dumps some json data (user info, etc). Now
Say I have a REST API in java, and it supports responses that are
I've read about oAuth, Amazon REST API, HTTP Basic/Digest and so on but can't
I have a service layer that I would like to convert into a webservice.
Some popular words, like food, are used all over the world as loan words.

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.