concept JSON in category security

appears as: JSON, JSON
API Security in Action

This is an excerpt from Manning's book API Security in Action.

Different API styles are suitable for different environments. For example, an organization that has adopted a microservices architecture might opt for an efficient RPC framework to reduce the overhead of API calls. This is appropriate because the organization controls all of the clients and servers in this environment and can manage distributing new stub libraries when they are required. On the other hand, a widely used public API might be better suited to the REST style using a widely used format such as JSON to maximize interoperability with different types of clients.

Figure 2.1 Natter exposes two APIs – one for normal users and one for moderators. For simplicity both share the same database. Mobile and web clients communicate with the API using JSON over HTTP, although the APIs communicate with their database using SQL over JDBC.

The idea behind stateless tokens is simple. Rather than store the token state in the database, you can instead encode that state directly into the token ID and send it to the client. For example, you could serialize the token fields into a JSON object, which you then base64url-encode to create a string that you can use as the token ID. When the token is presented back to the API, you then simply decode the token and parse the JSON to recover the attributes of the session.