Posts

Introduction to RESTful API Modeling Language (RAML)

Introduction to RESTful API Modeling Language (RAML) 1. Overview RAML is a YAML based language which is built on YAML1.2 and JSON for describing RESTful APIs. It provides all the information necessary to describe Restful API. It focuses on cleanly describing resources, methods, parameters, responses, media types, and other HTTP constructs that form the basis for modern APIs that obey many, though perhaps not all, Restful constraints. 2. Requirement Before jumping to RAML. Let’s assume we have to create one web application which is exposing CRUD Operations and couple of query parameters to access USER resources: · POST /api/v1/users · GET /api/v1/users · GET /api/v1/users?username={username} · GET /api/v1/users/{userId} · PUT /api/v1/users/userId{} · DELETE /api/v1/users/{userId} All the API’s are secured via Basic Authentication and all the communication will be done over HTTPS and all the request response will be in JSON format. 3. Implementation ...

Private method in Java 9

Image
As we know till Java 7, we are not allowed to add any concrete function to the Interface, All the function should be abstract and must be implemented in Child class which is implementing the interface. i.e. an interface can only have Constant variable abstract method With Java 8, we can add static and default method as well in an Interface. Check my blog on Java 8 for more details. So, an Interface now can have Constant Variable Abstract Method Default Method Static Method and with Java 9, It become more powerful and now we can add private method and private static method. but why do we need private function in an Interface. Let’s understand this with an example. In above example, we can observe that all the default function has same code to create database connection (duplicate code) and fetching the data and database details is also exposed to outside the world. So over here, Private method will come to rescue. Che...

Access User Profile API via Google OAuth 2.0 Playground ?

Image
The OAuth Playground is an application/tool by Google for learning how OAuth works. It presents you with a three-step process for selecting the services you want to authorize, generating an access token, and making API requests. In OAuth terminologies, Google OAuth playground will act as a client Application which does contain client id, Client secret and OAuth Endpoints required to access Service provider. It also supports custom endpoints as well i.e. using Google OAuth playground you can connect to another service provider as well apart from Google like Salesforce. Resource Owner:  You Client Application:  Google OAuth 2.0 Playground Service Provider:  Google In this blog, I’ll only focus on Google API and will try to retrieve user profile via playground. Step 1: Hit https://developers.google.com/oauthplayground/ Step 2: You will see a list of scope using which you can access particular resources. As our aim is to fetch user profile so will...