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

How do OAuth 1 differ from OAuth 2

Post cover: How do OAuth 1 differ from 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 to securely access third-party applications to user resources without passing a password. The basic idea was that a third-party service could make requests on behalf of the user, but each request was signed cryptographically, to ensure that it is not modified and comes from an authorized customer.
Features of OAuth 1:
  • Cryptographic signature of each request (HMAC-SHA1 or RSA-SHA1).
  • Used two types of tokens: request token to start authorization and access token to access resources.
  • Could work even without HTTPS because the security was ensured by the signature of the request.
  • Suitable mainly for server applications and a limited number of authorization scenarios.
OAuth 1 was actively used in services such as Twitter API v1 or older versions of LinkedIn, but due to implementation difficulties and signature problems, it was gradually replaced by OAuth 2.

OAuth 2

OAuth 2 appeared in 2012 as a simplified, more flexible and modern version of the protocol for authorization and access to resources. Its goal is to make the work of developers easier, to allow different types of customers (web, mobile applications, SPA) to easily access user resources without passing a password.
Features of OAuth 2:
  • Uses access tokens (access token) and optionally refresh token. Access token short-term, refresh token allows you to continue the session.
  • Does not require a cryptographic request signature - security is provided through HTTPS.
  • Supports various authorization streams: authorization code (for server web clients), implicit (for SPA), password (for trusted clients) and client credentials (for server-server interaction).
  • Much easier to implement and supported by modern APIs (Google, Facebook, GitHub, Microsoft, Stripe, etc.).
When is better to use:
  • OAuth 1: If you're working with very old APIs that need it, or in an HTTPS-free environment where query-level cryptography is important.
  • OAuth 2: for modern web and mobile applications, SPA, API where HTTPS is guaranteed. Also convenient for third-party customers, because it supports refresh tokens and various authorization streams.

Comparison of OAuth 1 and OAuth 2 in practice

  • Difficulty: OAuth 1 is more complex due to signatures, OAuth 2 is simpler and more flexible.
  • Safety: OAuth 1 is safe even without HTTPS, OAuth 2 needs HTTPS.
  • Flexibility: OAuth 1 is limited, OAuth 2 supports many authorization threads.
  • Usage today: OAuth 1 is almost unused, OAuth 2 is the standard for modern APIs and services.
OAuth 1 was about secure authorization without HTTPS, OAuth 2 - 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 Rails developers
04 Oct 19:06

What is Row Security in PostgreSQL and why is it 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
Basic methods of authentication in the API
19 Oct 20:26

Basic methods of authentication in the 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 sites communicate with AI
04 Nov 11:43

MCP: A new internet where sites 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