Understanding OAuth2

 What is OAuth2?

OAuth2.0 is an open authorization protocol, which allows accessing the resources of the resource owner by enabling the client applications on HTTP services such as Facebook, GitHub, etc. It allows sharing of resources stored on one site to another site without using their credentials. It uses username and password tokens instead.

Why Use OAuth 2.0?

  • You can use OAuth 2.0 to read data of a user from another application.

  • It supplies the authorization workflow for web, desktop applications, and mobile devices.

  • It is a server side web app that uses authorization code and does not interact with user credentials.

Features of OAuth 2.0

  • OAuth 2.0 is a simple protocol that allows to access resources of the user without sharing passwords.

  • It provides user agent flows for running clients application using a scripting language, such as JavaScript. Typically, a browser is a user agent.

  • It accesses the data using tokens instead of using their credentials and stores data in online file system of the user such as Google Docs or Dropbox account.

Advantages of OAuth 2.0

  • OAuth 2.0 is a very flexible protocol that relies on SSL (Secure Sockets Layer that ensures data between the web server and browsers remain private) to save user access token.

  • OAuth 2.0 relies on SSL which is used to ensure cryptography industry protocols and are being used to keep the data safe.

  • It allows limited access to the user's data and allows accessing when authorization tokens expire.

  • It has ability to share data for users without having to release personal information.

  • It is easier to implement and provides stronger authentication


Roles

OAuth2 defines 4 roles :

Resource Owner: generally yourself.
Resource Server: server hosting protected data (for example Google hosting your profile and personal information).
Clientapplication requesting access to a resource server (it can be your PHP website, a JavaScript application or a mobile application).
Authorization Serverserver issuing access token to the client. This token will be used for the client to request the resource server. This server can be the same as the authorization server (same physical server and same application), and it is often the case.

Tokens

Tokens are random strings generated by the authorization server and are issued when the client requests them.

There are 2 types of token:

Access Token: 
This is the most important because it allows the user data from being accessed by a third-party application. This token is sent by the client as a parameter or as a header in the request to the resource server. It has a limited lifetime, which is defined by the authorization server. It must be kept confidential as soon as possible but we will see that this is not always possible, especially when the client is a web browser that sends requests to the resource server via JavaScript.

Refresh Token: This token is issued with the access token but unlike the latter, it is not sent in each request from the client to the resource server. It merely serves to be sent to the authorization server for renewing the access token when it has expired. For security reasons, it is not always possible to obtain this token. We will see later in what circumstances.

 Access token scope

The scope is a parameter used to limit the rights of the access token. This is the authorization server that defines the list of the available scopes. The client must then send the scopes he wants to use for his application during the request to the authorization server. More the scope is reduced, the greater the chance that the resource owner authorize access.


Comments

Popular posts from this blog

Email Sending through O365 using OAuth Protocol

IISRESET vs App Pool Recycling ?

Deploy .Net6.0 Web api with docker