Ever Wondered How Your Favorite Apps Keep You Securely Logged In? Discover OAuth 2.0!
- Pranami Jhawar
- Mar 31
- 4 min read
Imagine you’re logging into your favorite app and instead of creating a new account, you simply hit the button that says "Login with Google" or "Login with Facebook." Within seconds, you’re in, without needing to remember yet another password. That’s OAuth 2.0 in action!

What is OAuth 2.0?
OAuth 2.0 is like giving a valet the keys to your car - they can park it, but they can't take it for a joyride. It’s an industry-standard protocol for authorization that allows apps to obtain limited access to your accounts on different services without ever sharing your actual password.
For example, when a fitness app wants to access your step count from Google Fit, it doesn’t need your Google password. Instead, OAuth 2.0 facilitates a secure way to grant that access without compromising your personal data.
Why is OAuth 2.0 Widely Used?
OAuth 2.0 has become the go-to standard because it keeps user data safe while simplifying the login process. Think about how many times you’ve used the “Sign in with Google” button. Instead of managing dozens of usernames and passwords, OAuth 2.0 lets you seamlessly move between apps with your existing credentials.
Connecting Authentication and Authorization in OAuth 2.0
In our previous blog, we discussed the difference between authentication and authorization. If you haven't checked it out yet, you can read it here. OAuth 2.0 beautifully combines both processes to streamline secure access to resources.
Authentication in OAuth 2.0: This is the step where the identity provider (like Google or Microsoft) verifies your identity. For example, when you click “Login with Google,” you are first asked to enter your credentials. This is the authentication phase.
Authorization in OAuth 2.0: Once your identity is confirmed, OAuth 2.0 takes care of granting permissions. The application then requests an authorization token, which defines what it is allowed to do on your behalf (like accessing your profile information).
A good analogy is checking in at a hotel. You first show your ID (authentication), and then the hotel gives you a room key that grants you access to specific areas (authorization). OAuth 2.0 follows a similar pattern, ensuring that apps get limited access without compromising your credentials.
Scopes and Roles in OAuth 2.0
OAuth 2.0 uses scopes and roles to define what an application can access and what permissions a user has within that application.
Imagine you’re using a team collaboration tool like Microsoft Teams through your company’s single sign-on (SSO) system. You log in with your company credentials, and once authenticated, the app requests specific permissions:
Scopes: The app might request permission to view your profile, calendar, or documents. Each permission corresponds to a scope. For instance, 'read:calendar' allows the app to access your calendar data but not modify it. Scopes help define the specific actions that the app is allowed to perform on your behalf.
Roles: Your role in the system could be 'Admin' or 'User'. An Admin role might allow you to manage team settings and invite new members, while a User role might limit you to viewing channels and sending messages. Roles determine what level of control and access you have within the application.
This way, OAuth 2.0 ensures that even within the same app, different users might have different levels of access, and apps only get the minimum permissions needed to function. By clearly defining scopes and roles, OAuth 2.0 not only secures the data but also ensures that users have the appropriate level of access based on their role within the system.
Key Components of OAuth 2.0 Flows
Let’s break down the key components using a relatable example: accessing a cloud storage service like Google Drive through a photo editing app (like Canva).
Resource Owner: You, the user, who owns the photos stored on Google Drive.
Client: Canva, the app that wants to access your Google Drive to import photos for editing.
Authorization Server: Google’s server that verifies your credentials when you log in via Canva.
Resource Server: The server where your Google Drive photos are stored.
Access Token: The temporary key that Canva uses to access your Google Drive photos on your behalf.
Refresh Token: A longer-lived token that allows Canva to obtain new access tokens without requiring you to log in again.
Imagine you’re using Canva to create a collage and want to import a photo from your Google Drive. You click “Connect with Google,” log in, and give permission to access your photos. Google (the Authorization Server) then gives Canva (the Client) a temporary access token to fetch the photo without revealing your password.
Brief Introduction to OAuth 2.0 Flows
OAuth 2.0 offers several ways (flows) for apps to request access:
Authorization Code Flow: Like handing a ticket to the security guard - they verify it and let you in.
Implicit Flow: Quicker but less secure - imagine flashing an ID to get quick access.
Client Credentials Flow: The app itself, rather than the user, gets permission - like an employee badge giving access to staff-only areas.
Resource Owner Password Credentials Flow: You give the app your password directly - like giving someone your house keys (not recommended!).
Wrapping Up
OAuth 2.0 is a powerful protocol that enhances security by allowing users to grant limited access to their data without sharing their credentials. It’s widely adopted because it’s versatile and supports various use cases, from logging in to apps with your social accounts to allowing secure API integrations.
In the next posts, we will dive deeper into each OAuth 2.0 flow, discuss real-world scenarios, and cover best practices for secure implementation.
Comments