OAuth (Open Authorization) is an open standard protocol for authorization that allows applications to access a user's resources without knowing their credentials (e.g., password). It is commonly used for Single Sign-On (SSO) and API access.
How Does OAuth Work?
OAuth operates using tokens, which allow an application to access a user's data on their behalf. The typical flow is as follows:
- Authorization Request: An application (client) requests access to a user’s protected data (e.g., Facebook contacts).
- User Authentication: The user is redirected to the provider's login page (e.g., Google, Facebook) and enters their credentials.
- Permission Granting: The user confirms that the application can access specific data.
- Token Issuance: The application receives an access token, which grants permission to access the approved data.
- Resource Access: The application uses the token to make requests to the API server without needing the user's password.
OAuth 1.0 vs. OAuth 2.0
- OAuth 1.0: More complex, uses cryptographic signatures but is secure.
- OAuth 2.0: Simpler, relies on HTTPS for security, and is the most commonly used version today.
Real-World Uses of OAuth
- "Sign in with Google/Facebook/Apple" buttons
- Third-party apps accessing Google Drive, Dropbox, or Twitter APIs
- Payment services like PayPal integrating with other apps