Servage Magazine

Information about YOUR hosting company – where we give you a clear picture of what we think and do!

Articles Tagged ‘json’

API authentication using JSON web tokens

Wednesday, November 29th, 2017 by Servage
json-jwt-tokenThere are many ways to authenticate users in APIs: username and password combinations, OAuth 2 and API keys to name a few. Today we will be having a look at a rather new implementation called JSON Web Token, JWT for short. There are some noteworthy advantages in JWTs that we will be covering as well. What is a JWT? A JWT is a way to send and receive data between two parties in a secure way. The data a JWT contains is mostly up to you, although some metadata must be present. JWTs can be used as session tokens to authenticate against an API. As the name implies, a JWT is JSON and therefore ...

HTTP requests with the new Angular 4 HTTP Client

Tuesday, November 7th, 2017 by Servage
angular-4Angular 4.3 comes with a new way of sending HTTP requests: the HttpClient class. The older Http class can still be used and it is not deprecated, at least for now. However, HttpClient brings some new features and will likely replace the old class in the future. Let’s go through some of the features the new HttpClient has to offer. Modifying Requests with Interceptors One of the handy new features is the ability to intercept HTTP requests with interceptors. Intercepting a request means modifying it on the fly. One common use case for interceptors is to attach a session token to every request automatically to easily authenticate with an API. Interceptors are classes that ...

Handling JSON with PHP

Monday, September 12th, 2016 by Servage
jsonJSON is a data serialization format that has become the de-facto standard for transmitting data between applications. It is more and more often preferred over its competitor XML thanks to being lightweight, human-readable and widely supported. JSON is also supported by PHP, so let’s see how PHP can be used to read and write JSON. Creating a JSON Object PHP has two functions that are often used to deal with JSON: json_encode() and json_decode(). These functions have been built in to PHP since 5.2.0. First, let’s see how we can use json_encode to create a new JSON object. Before we get started, it’s good to know what kind of data can be turned ...