---
description: This chapter is dedicated to the OAuth 2.0 protocol itself.
---

# What is OAuth 2?

## OAuth 2 protocol

OAuth 2 is the most common protocol for authorization. The protocol allows services and application to get access to specific scopes of data.

{% hint style="info" %}
Also check [RFC 6749 "The OAuth 2.0 Authorization Framework"](https://datatracker.ietf.org/doc/html/rfc6749)!
{% endhint %}

## OAuth 2 roles

The protocol defines four roles:

Client: a system that requires access to some protected resourses;

Resourse Owner: the system or a person that owns the resource and can grant access to it. When the resource owner is a person, it is referred to as an end-user;

Authorization Server: the server that can issue Access Token to the client upon authentication and consent by the resource owner;

Resourse Server: the server that get request to the specific protected resources from the client and returns this resources if client's Access Token is valid.

{% hint style="info" %}
Resource owner in the Humanode OAuth 2 Service is always a real and unique person!
{% endhint %}

![](https://3702472699-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fr9BYcyYNSxAhS6VoH9d2%2Fuploads%2F3pipSoRiDK9quIl4pK2l%2FRoles.png?alt=media\&token=b60647db-3c9c-4618-8ad9-6d65d0a6f707)

## OAuth 2 Tokens

Access Token can be used to get protected resources according to the scopes that resource owner give consent to.

Refresh Token is often granted by the authorization server alongside with Access Token. It can be used to get another pair of tokens when previous Access Token expired. Refresh Token has longer expiry time and is single-used.

![](https://3702472699-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fr9BYcyYNSxAhS6VoH9d2%2Fuploads%2FXMCCvM2e2btaAckprGdN%2FRefresh%20tokens.png?alt=media\&token=33b8a402-d0a6-4343-8ee2-104e739a8912)

[JSON Web Token](https://jwt.io/) or JWT is a method for representing Access Token. It contains all needed data about authorization server, client and resourse owner, as well as granted scopes. JWT is cryptografically signed by the authorization server and can be validated using public keys named JWT Key Sets or JWKs. JWKs are provided by the authorization server.

## Simple Examples

First example is a website "some-website" that allows it's users to show their email and/or profile picture from some social network. In this case Resourse owner is a user of a some-website and a social network, client is a some-website and a social media serves as authorization server and resourse server.

![](https://3702472699-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fr9BYcyYNSxAhS6VoH9d2%2Fuploads%2F5lfYs6x2eAwOLjAVcsw9%2FSimple%20Example%201.png?alt=media\&token=ecf3794d-8e60-4142-87d0-df320e39a871)

Second example is a website "some-website" that allows users to authenticate via some social network. Resourse owner now is a user of a social network, authorization server is a social network and both client and resource server is a some-website.

![](https://3702472699-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fr9BYcyYNSxAhS6VoH9d2%2Fuploads%2Fo9QirzGh90QwgbCT77Pf%2FSimple%20Example%202.png?alt=media\&token=1c27d9bd-1614-40ff-b026-ce6e5573d1dc)

The special scope "openid" which are part of OpenID Connect protocol are used for authentication. More about this protocol is in it's dedicated page.

{% content-ref url="openid-connect" %}
[openid-connect](openid-connect)
{% endcontent-ref %}
