OAuth Server

What is OAuth 2.0

OAuth 2 is an authorization framework that enables applications to obtain limited access to user accounts on an HTTP service, such as Facebook, GitHub, and Google. It works by delegating user authentication to the service that hosts the user account and authorizing third-party applications to access the user account. OAuth 2 provides authorization flows for web and desktop applications, and mobile devices.

OAuth Roles

OAuth defines four roles:
  • Resource
  • OwnerClient
  • Resource Server
  • Authorization Server

How its woks

Here I have created the both authorization server and resource server in a single api in node.js.  and angular for the demo application.
First create a demo application in OAuth application setting in github.


To get the access code, use a GET request in the login page.





After successfully login page will redirect to http://localhost:4200/posts (call back URL) and it will shows the access token


Then server sends a POST call to generate access token.


Then we can call the GET request for get user information.


In the Demo Application it will show as below.


You can download the source code here and follow the steps in the repo to run the application.

Comments

Popular posts from this blog

OrientDB Quick Guide

Cron Expressions

Double Submit Cookies Pattern