Engineering
October 10, 2023
6 min read

OpenID vs OAuth: Understanding API Security Protocols

Axandria Shepard

When it comes to digital identity, OpenID and OAuth are two peas in a pod, but they have their differences. OpenID connects you to relying parties using a single sign-on, while OAuth grants access tokens so you can give apps limited access. 

They both make authentication simple, seamless, and secure. However, don't be fooled: behind the scenes, they're as different as night and day. OpenID is about logging you in, while OAuth is all about letting apps in. 

In this article, we will go a bit deeper into the core differences between OpenID and OAuth and how to choose the right method for your needs.

Note: If you're ready to get started with OAuth or OpenID Connect workflows you can get started for free in Kong Konnect. Sign up and leverage our OpenID authorization code flow plugin guide.

What is OpenID?

OpenID is an open standard that enables decentralized digital identity, allowing users to log into different websites using the same identity provider. For example, there are SSO options where you can use your Google or Facebook account to sign in to various sites across the web, without needing to create new usernames and passwords for each one. 

One of the advantages of OpenID is its convenience and portability. By having to remember multiple sets of login credentials OpenID allows you to rely on a single identity provider for authentication. This means that you can easily carry your identity with you when accessing different websites.

However, it's important to consider the drawbacks as well. With OpenID, there’s a risk associated with having a point of failure. If your OpenID provider gets compromised all the websites where you use it could be affected too. It's crucial to understand these tradeoffs in order to determine whether OpenID is suitable for your needs or not. While it streamlines the sign-in process relying on third-party providers also introduces privacy and security concerns.

What is OAuth?

OAuth is an authorization protocol that enables users to grant limited access to their data on one site to another site or application without exposing their credentials. For example, you can allow a third-party app to access your photos stored with a social media site by authorizing it via OAuth without providing your social media password.

The main benefit is it gives users safer delegated authorization compared to sharing passwords directly. Users can grant limited access and revoke it at any time. 

However, OAuth also comes with complexity for developers and some risks for users. The authorization steps require user education. Users should be careful in reviewing permissions granted to apps via OAuth and not blindly authorize access to sensitive data. While it enables secure data sharing between sites, users must assess if the tradeoffs are appropriate for specific use cases.

What is OAuth 2.0?

OAuth 2.0 is the latest version of the OAuth open authorization standard that enables secure delegated access for apps and APIs to protected user data. It introduces several API security enhancements including new cryptographic methods and authorization code grants. 

OAuth 2.0 also provides greater simplicity for developers and optimized flows for web, mobile, and desktop apps authorization. New grant types focus on client developer ease of use and enhanced security for users. Overall, OAuth 2.0 establishes itself as the industry standard for its flexible yet secure authorization framework that enables third-party apps and APIs to safely access user data on other sites.

Business considerations: OAuth vs OpenID

OpenID focuses on user authentication while OAuth is for delegated authorization. OAuth's flexibility has led to wider industry adoption while OpenID is simpler but less customizable. Understanding their key differences helps apply them in appropriate use cases.

Purpose

  • OpenID is an authentication protocol used for signing users into client applications. The purpose is user authentication.
  • OAuth is an authorization protocol used for providing client applications delegated access to server resources on behalf of a user. The purpose is delegated authorization.

Flow

  • OpenID involves an authentication request that redirects the user to the OpenID provider for authentication. After signing in there, the user is redirected back.
  • OAuth uses token exchange behind the scenes between the client, resource server, and authorization server. No redirection is involved.

Scope

  • OpenID verifies the end-user identity but provides no other user information. Its scope is restricted to authentication only.
  • OAuth verifies and grants specific access to protected resources, with customizable scopes. The access is restricted to the delegated scope.

Usage

  • OpenID is commonly used for web single sign-on. Social sign-in via Google/Facebook/etc is based on OpenID.
  • OAuth allows users to grant third-party applications access to their data on other sites like social media or cloud storage.

Standard

  • OpenID is an open standard specification. Multiple providers can offer OpenID identity services.
  • OAuth is a framework with competing versions like 1.0, 2.0, and 3.0. It has multiple extension grant types.

Complexity

  • OpenID does not use tokens. The protocol flow is simpler to implement for developers.
  • OAuth uses signed tokens and involves more steps of token exchange. It is more complex to implement.

Customization

  • OpenID offers little customization - it's designed for simple single sign-on use cases.
  • OAuth allows extensive customization of token scope, endpoints, expiration, refresh, etc.

Adoption

  • OpenID lost traction as social login using Facebook, Google, etc. became popular.
  • OAuth is widely adopted across the industry for mobile apps, web APIs, and third-party access to user data.

Protect Mission-Critical APIs & Services: Efficient protection strategies revealed

OpenID Connect (OIDC): The Best of Both Worlds

OpenID Connect is an authentication protocol that extends OAuth 2.0 and can be utilized for sign-on purposes. It facilitates the verification of user identity by clients through an authorization server. OpenID Connect combines elements from both OpenID and OAuth:

It employs OAuth 2.0 flows for the authentication request and response enabling a seamless single sign-on experience similar to OpenID. Additionally, it incorporates an OAuth 2.0 token that allows clients to access APIs and retrieve user information.

Consequently, OpenID Connect offers both identity verification and delegated authorization capabilities enabling clients to securely access user data. By augmenting OAuth 2.0 with an identity layer featuring user profile claims OpenID Connect provides a means of achieving single sign-on functionality on top of the authorization framework offered by OAuth.

Choosing Between OpenID OAuth, and OpenID Connect (OIDC)

When it comes to designing authentication and authorization for an application there are three used protocols; OpenID, OAuth, and OpenID Connect. It's crucial to understand the strengths of each protocol in order to make the choice as one becomes an API-first company

OpenID is ideal for scenarios where we need to verify a user's identity through single sign-on. If we want to integrate login or allow users to sign in easily across multiple sites OpenID is a straightforward option.

OAuth on the other hand is great when an application needs access to protected resources related to a user. It allows authorization by using tokens without exposing user credentials. OAuth is preferred when authorizing API access or enabling third-party apps.

OpenID Connect combines the identity verification capabilities of OpenID with the delegated access features of OAuth. It builds on top of OAuth 2.0. Offers both single sign on for users and authorized access to user data for clients. However, it also inherits the complexity associated with OAuth.

By evaluating specific use cases related to authentication API integration and user experience we can select the most suitable protocol that balances simplicity, security, and functionality. Understanding the core purposes of OpenID, OAuth, and OpenID Connect is essential in making a decision.

Conclusion 

OpenID and OAuth are two common protocols used for online identity and API access control. While OpenID is focused on user authentication for single sign-on, OAuth enables delegated authorization for applications accessing user data. Understanding that OpenID verifies identity and OAuth grants limited access is crucial. Developers should also note differences in protocol flows, standardization, complexity, and customizability when selecting the right protocol. Overall, both OpenID and OAuth have their place in enabling secure digital identity and authorized access, with OAuth seeing wider adoption for APIs and third-party apps integration.

Continued Learning and Related Content