OAuth is an open authorization protocol that allows consumer applications on Web platforms such as Twitter, GitHub, or others to access the resource owner’s resources. The IETF OAuth Working Group developed OAuth 2.0 in 2012.

OAuth 2.0 focuses on the usability of product developers and offers unique authorization flows for web applications, desktop applications, mobile phones, and devices in the living room.

OAuth 2.0 framework defines several grant types for different use cases, as well as the framework for creating new grant types. In OAuth 2.0, the term “grant type” refers to the way an application gets an access token.

The basic grant type for OAuth 2.0 are listed below:

  • Authorization Code
  • Password
  • Client Credentials
  • Refresh Token

Table Structure

users

| Column                  | Data Type
|----------               |-------------
| id                      | int
| name                    | string
| username                | string
| password                | string
client
| Column                  | Data Type
|----------               |-------------
| id                      | int
| client_id               | string
| client_secret           | string
| name                    | string
| home_page_url           | string
| logo_url                | string
| privacy_policy_url      | string
| user_id                 | string
| is_live                 | bool
| redirect_uri            | []string
client_access_tokens
| Column                  | Data Type
|----------               |-------------
| id                      | int
| client_id               | int
| user_id                 | int
| client_refresh_token_id | int
| access_token            | string
| grant_type              | string
| scope                   | string
| audience                | string
| expired_at              | datetime
client_refresh_tokens
| Column                  | Data Type
|----------               |-------------
| id                      | int
| client_id               | int
| user_id                 | int
| refresh_token           | string
| grant_type              | string
| scope                   | string
| audience                | string
| expired_at              | datetime
client_authorization_codes
| Column                  | Data Type
|----------               |-------------
| id                      | int
| client_id               | int
| user_id                 | int
| code                    | string
| scope                   | []string
| is_used                 | bool
| redirect_uri            | string
| expired_at              | datetime

#oauth #javascript #authentication #web-development #programming

Simple OAuth 2.0 Implementation
1.10 GEEK