Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which HTTP method should Login and Logout Actions use in a "RESTful" setup

Tags:

rest

Curious how others here would represent these in a REST architecture.

/users/login/ /users/logout/ 

These endpoints set up the session to login in the user, or clear it, respectively. My gut says POST, but I'm not in fact creating an object.

like image 571
onassar Avatar asked Feb 26 '13 20:02

onassar


People also ask

Which HTTP method should be used for login?

In MOST cases, forms should use the post method. In the case of logins, that would be ALWAYS use post.

Which HTTP method is the most commonly used by REST API?

The primary or most-commonly-used HTTP verbs (or methods, as they are properly called) are POST, GET, PUT, PATCH, and DELETE. These correspond to create, read, update, and delete (or CRUD) operations, respectively.


1 Answers

You should use POST - using GET for these actions can lead to issues with browser prefetching and search engine spidering. See (1, 2)

like image 59
Yaakov Ellis Avatar answered Oct 01 '22 20:10

Yaakov Ellis