REST API unauthenticated requests exception based on the User-Agent

Posted by Shay Tsadok on Stack Overflow See other posts from Stack Overflow or by Shay Tsadok
Published on 2010-04-27T20:54:35Z Indexed on 2010/04/28 0:23 UTC
Read the original article Hit count: 308

Filed under:
|
|
|
|

Hi All,

I am developing a REST API that supports two kinds of authentication protocols:

  1. login form authentication - for browser based clients.
  2. Simple Basic authentication - for non-browser clients.

I developed a flow in which unauthenticated requests redirected to the "login form", the problem is that this is an undesired behavior for non-borwser clients!

I thought to solve it by decide according to the "User-Agent" what to do: browsers will be redirected to the "login form" and non-browser clients will get the standard 401:Basic Authentication.

A. What do you think about this solution?
B. Is there a standard way in Java to check if the request came from browser, or do i need to develop this kind of mechanism by my own?

Thanks in advance!

© Stack Overflow or respective owner

Related posts about rest

Related posts about java