What is OAuth 2.0?
OAuth 2.0 is an authorization framework that enables third-party applications to obtain limited access to user accounts without exposing user credentials. Instead of sharing passwords, users authenticate with the service provider (bank) directly and authorize specific access for the third-party application. OAuth separates authentication (proving identity) from authorization (granting access), creating a more secure and flexible system than traditional credential sharing.
OAuth Authorization Code Flow with PKCE
The Authorization Code Flow with Proof Key for Code Exchange (PKCE) is the recommended OAuth flow for mobile and web applications accessing financial data. PKCE adds an extra layer of security preventing authorization code interception attacks. The flow involves: 1) Application generates code verifier and challenge. 2) User redirected to authorization server with challenge. 3) User authenticates and consents. 4) Authorization server returns authorization code. 5) Application exchanges code for access token using verifier. 6) Access token used to call APIs. PKCE is mandatory for CDR and recommended for Section 1033 implementations.
Access Tokens and Refresh Tokens
Access tokens are short-lived credentials (typically 10-60 minutes) used to call APIs on behalf of the user. Refresh tokens are long-lived credentials used to obtain new access tokens without user interaction. In financial APIs, refresh tokens are typically valid for the consent duration (e.g., 90 days in Section 1033, up to 12 months in CDR). Applications must securely store refresh tokens and implement automatic token refresh when access tokens expire.
Token Storage Security
Never store tokens in localStorage or sessionStorage where they're vulnerable to XSS attacks. For web applications, store tokens in httpOnly, secure cookies. For mobile applications, use platform-specific secure storage (iOS Keychain, Android Keystore). Implement token encryption at rest and secure memory handling during processing.
Token Revocation
Implement proper token revocation when users log out or revoke consent. Call the authorization server's revocation endpoint to invalidate refresh tokens. Clear all stored tokens from application state. Financial regulations often require immediate revocation when users withdraw consent.
Consent and Scope Management
OAuth scopes define the specific data and permissions being requested. Financial APIs define standardized scopes for different data types (e.g., "bank:accounts:read", "bank:transactions:read", "bank:payees:read"). Applications should request only the minimum scopes necessary for their functionality. Consent screens must clearly explain what data is being accessed and for what purpose. Users should be able to grant granular consent for specific data types.
OpenID Connect for Authentication
OpenID Connect (OIDC) is an authentication layer built on OAuth 2.0. While OAuth handles authorization, OIDC handles user authentication and identity verification. OIDC provides an ID token (JWT) containing user identity claims alongside the OAuth access token. Financial APIs often use OIDC for Know Your Customer (KYC) and identity verification requirements. The ID token can include verified identity attributes like name, email, and phone number.
Financial-Grade API (FAPI) Security
Financial-Grade API (FAPI) is an OpenID Foundation security profile providing enhanced protection for high-risk transactions. CDR requires FAPI 2.0 compliance, and other financial APIs are adopting FAPI standards. Key FAPI requirements include: Mutual TLS (mTLS) for client authentication, JWT-secured authorization requests, sender-constrained tokens preventing token theft, and hybrid flow with code and ID token in front channel. FAPI provides bank-grade security protecting against sophisticated attacks.
Implementation Best Practices
Follow these OAuth implementation best practices for financial APIs: Always use HTTPS for all OAuth communications. Validate redirect URIs strictly (exact match, no wildcards). Implement PKCE for all flows, even confidential clients. Use short-lived access tokens (15-60 minutes maximum). Rotate refresh tokens on each use. Implement rate limiting on token endpoints. Log all authorization events for audit trails. Use nonces to prevent replay attacks. Validate JWT signatures and claims. Implement proper error handling without leaking security information. Test OAuth flows comprehensively including error cases and revocation scenarios.