All original content is created in Ukrainian. Not all content has been translated yet. Some posts may only be available in Ukrainian.Learn more

What are the differences between OAuth 1 and OAuth 2

Post cover: What are the differences between OAuth 1 and OAuth 2
Table of contentsClick link to navigate to the desired location
This content has been automatically translated from Ukrainian.

OAuth 1

OAuth 1 was developed in the early 2000s as a way for third-party applications to securely access user resources without sharing the password. The main idea was that a third-party service could make requests on behalf of the user, but each request was cryptographically signed to ensure that it was unaltered and came from an authorized client.
Features of OAuth 1:
  • Cryptographic signature for each request (HMAC-SHA1 or RSA-SHA1).
  • Used two types of tokens: request token to initiate authorization and access token to access resources.
  • Could work even without HTTPS, as security was provided by the request signature.
  • Primarily suited for server-side applications and a limited number of authorization scenarios.
OAuth 1 was actively used in services like Twitter API v1 or older versions of LinkedIn, but due to its complexity in implementation and signature issues, it was gradually replaced by OAuth 2.

OAuth 2

OAuth 2 emerged in 2012 as a simplified, more flexible, and modern version of the protocol for authorization and access to resources. Its goal is to make developers' work easier, allowing different types of clients (web, mobile applications, SPA) to easily access user resources without sharing the password.
Features of OAuth 2:
  • Uses access tokens and optionally refresh tokens. Access tokens are short-lived, while refresh tokens allow for session continuation.
  • Does not require a cryptographic signature for requests - security is provided through HTTPS.
  • Supports various authorization flows: authorization code (for server-side web clients), implicit (for SPA), password (for trusted clients), and client credentials (for server-to-server interactions).
  • Much easier to implement and supported by modern APIs (Google, Facebook, GitHub, Microsoft, Stripe, etc.).
When to use what:
  • OAuth 1: if you are working with very old APIs that require it, or in an environment without HTTPS where request-level cryptography is important.
  • OAuth 2: for modern web and mobile applications, SPA, APIs where HTTPS is guaranteed. Also convenient for third-party clients as it supports refresh tokens and various authorization flows.

Comparison of OAuth 1 and OAuth 2 in practice

  • Complexity: OAuth 1 is more complex due to signatures, OAuth 2 is simpler and more flexible.
  • Security: OAuth 1 is secure even without HTTPS, OAuth 2 requires HTTPS.
  • Flexibility: OAuth 1 is limited, OAuth 2 supports many authorization flows.
  • Usage today: OAuth 1 is rarely used, OAuth 2 is the standard for modern APIs and services.
OAuth 1 was about secure authorization without HTTPS, OAuth 2 is about flexibility, simplicity, and modern scenarios for web and mobile applications.

This post doesn't have any additions from the author yet.

What is factorial complexity?
16 Sep 19:03

What is factorial complexity?

meme code
meme code@memecode
What is NP-complexity?
16 Sep 19:31

What is NP-complexity?

meme code
meme code@memecode
Offset vs Cursor Pagination in Rails: what to choose and why
24 Sep 15:22

Offset vs Cursor Pagination in Rails: what to choose and why

meme code
meme code@memecode
What is Row Security in PostgreSQL and why is it important for Rails developers
04 Oct 19:06

What is Row Security in PostgreSQL and why is it important for Rails developers

meme code
meme code@memecode
What is ivar in Ruby / Rails?
19 Oct 20:12

What is ivar in Ruby / Rails?

meme code
meme code@memecode
Main methods of authentication in API
19 Oct 20:26

Main methods of authentication in API

meme code
meme code@memecode
What is ORM and why is it needed?
26 Oct 14:00

What is ORM and why is it needed?

meme code
meme code@memecode
MCP: a new internet where websites communicate with AI
04 Nov 11:43

MCP: a new internet where websites communicate with AI

meme code
meme code@memecode
Why is TOON better than JSON when working with AI?
14 Nov 15:14

Why is TOON better than JSON when working with AI?

meme code
meme code@memecode