user411103
user411103

Reputation:

Differentiate web and native app requests to Java Spring backend

Users can login to my service via web or via a native app (iOS or Android). The backend endpoint for authentication (Java Spring) is the same for all, but I need to differentiate if the REST (POST and GET) request is coming from a web browser or from a native mobile app, as I want to implement different session policies.

How can I do that?

Upvotes: 2

Views: 577

Answers (1)

duggu
duggu

Reputation: 38429

So you need to make your authentication for all because IOS,Android and Web are front end which communicate to server for data. So you need to ask device OS to frontend guys in header so you can know where api call comes. Whenever they hit api to server they will send parameter in header.

        // android send data
        headers.put("device-os", "android");

or

        // IOS send data
        headers.put("device-os", "ios");

or

        // web send data
        headers.put("device-os", "web");

Note :- Above code android specific.

Upvotes: 4

Related Questions