Skip to content

Make Selenium Easy

And Keep It That Way

  • Home
  • Share
  • Toggle search form

#1. OAuth 2.0 Flow – How Does It Work?

Posted on 03/16/2025 By admin

OAuth 2.0 is the industry-standard protocol for authorization for web applications. OAuth 2.0 enables third-party applications (Clients) to have limited access to the protected resources of a resource owner without sharing any credentials by the owner with the client.

We will learn how OAuth 2.0 work in this post.

Video tutorials help in better learning. You must watch the video below. But it is always a good practice to read and understand the articles as well.

If you navigate to the Signup/SignIn page of applications like Spotify, you must have seen options like SignIn using Facebook or Google as shown below.

When you click on these options then you are navigated to the official Facebook and Google account page where you are required to log in with Facebook or Google account credentials. You can also create an account on Facebook and Google if you don’t have one. Once you fill in your credentials, you will be redirected to Spotify with a profile created (SignUp) or homepage (Log In).

You don’t actually share your Facebook or Google account credentials with Spotify. Facebook and Google also do not share your credentials with Spotify. If you see the above image of the Google Account sign in then you can see a statement as “To continue, Google will share your name, email address, language preference, and profile picture with Spotify.“. Once you give your consent by logging in then Google shares your name, email address, profile picture, etc. with Spotify. These details are used by Spotify to create your account on their platform.

Google uses OAuth 2.0 for all these flows.

Please note here that OAuth 2.0 is for Authorization, not Authentication. Authentication is the process of verifying who a user is and authorization is the process of verifying what they have access to. But you will be thinking that SignIn with Google on Spotify is Authentication. In fact, Google APIs use the OAuth 2.0 protocol for authentication and authorization. But in the end, Spotify needs to call Google APIs with resource owner consent to access resource owner details which is Authorization.

Let’s see another real-time example. Create an account on the CVS Photo Print website. If you want to print any photos then you can upload photos from your Computer or you can upload photos from Google Photos as well. When you click on the “Connect to Google Photos” link the same process as Spotify will be repeated.

I have captured this flow from the official documentation of OAuth 2.0. The below diagram shows the OAuth 2.0 authorization flow.

A Client ( Spotify in the above real-time example) requests authorization from the resource owner i.e. You. At this step, You will be redirected to the authorization server where you need to provide your credentials. As we are taking an example of Google, then you need to pass your Google account credentials. Here Authentication takes place. The client must be registered with Google before requesting authorization from the resource owner.

If the resource owner authenticates successfully then an Authorization grant will be received by the Client. An authorization grant is a credential representing the resource owner’s authorization. This Authorization grant can be anyone from Authorization Code, Implicit grant, Resource owner password credentials, and Client credentials.

The client requests an access token from the Authorization server using the Authorization grant received in step B.

The authorization server authenticates the Client and validates the authorization grant and issues the access token to the client if valid.

Client requests for the protected resource of the resource owner (who authorizes it in step A) from the resource server using the access token. For example, the client i.e. Spotify may request for resource owner’s name, email address, profile picture, etc. from the Google server using Google APIs so that Spotify can create your user account on their platform.

The resource server validates the access token and serves the request if the access token is valid.

From the above flow, you must have understood the roles involved. There are four roles involved in OAuth 2.0 flow –

  1. Resource owner – An entity capable of granting access to a protected resource.
  2. Resource server – The server hosting the protected resources that is capable of accepting and responding to protected resource requests using access tokens.
  3. Client –  An application making protected resource requests on behalf of the resource owner and with its authorization.
  4. Authorization server – The server issues access tokens to the client after successfully authenticating the resource owner and obtaining authorization.

We will learn about Authorization Grants and their types in the next post.

Thanks for reading. Kindly comment for any feedback and suggesuggestions.

Uncategorized

Post navigation

Previous Post: Problems in Parallel Execution With Static WebDriver
Next Post: Frequently Asked Java Program 23: Java Program to Remove Extra WhiteSpace Between Words In Given String

Related Posts

TestNG Tutorials 53: DataProvider in TestNG – Is It Mandatory To Have Return Type as Object in DataProvider Method | Make Selenium Easy Uncategorized
RegenerateTestNG – Make Selenium Easy Uncategorized
Postman Tutorial Part 26 – Using Environment in Collection Runner Uncategorized
April 19, 2017 – Make Selenium Easy Uncategorized
API Testing Tutorial Part 9 – Difference Between REST and RESTFul API Uncategorized
February 26, 2018 – Make Selenium Easy Uncategorized

Recent Posts

  • Getting Started with Selenium 4: What Is New and How to Upgrade from Selenium 3
  • Manual Testing
  • Baby Steps To Become Efficient Selenium-Java Automation Tester
  • Features of Selenium 4.0.0 Release – Java Binding
  • Part 1: Handling Drop-down Created Using SELECT Tag In Selenium

Recent Comments

No comments to show.

Archives

  • April 2026
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • April 2024
  • March 2024
  • February 2024
  • December 2023
  • October 2023
  • August 2023
  • November 2022
  • September 2022
  • August 2022
  • July 2022
  • May 2022
  • March 2022
  • October 2021
  • April 2021
  • March 2021
  • January 2021
  • December 2020
  • October 2020
  • September 2020
  • August 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • May 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • January 2018

Categories

  • Getting Started
  • Uncategorized

Copyright © 2026 Make Selenium Easy.

Powered by PressBook Masonry Dark