OAuth Integration
Deva uses OAuth 2.0 with OpenID Connect (OIDC) for secure user authentication. The SDK implements the Authorization Code Flow with PKCE (Proof Key for Code Exchange), which is designed for client-side applications.
How OAuth Works in Deva SDK
The SDK handles the entire OAuth flow automatically. When a user clicks login:
Authorization Request - SDK generates a code challenge and redirects to Deva's login page
User Authentication - User logs in and grants permissions
Authorization Code - Deva redirects back with an authorization code
Token Exchange - SDK exchanges the code for access tokens
API Access - SDK uses the access token to fetch user data and make API calls
Token Refresh - SDK automatically refreshes expired tokens in the background
PKCE Flow (No Client Secret Required)
The SDK uses PKCE instead of client secrets, making it safe for browser-based applications:
Code Verifier: Random string generated by the SDK
Code Challenge: SHA-256 hash of the code verifier
No Secrets: Client secret is not needed or exposed in the browser
This prevents authorization code interception attacks in public clients.
OpenID Configuration
Deva's OpenID configuration provides all OAuth endpoints and supported features:
Configuration URL:
https://www.deva.me/.well-known/openid-configurationKey Endpoints:
authorization_endpoint- Where users log intoken_endpoint- Where codes are exchanged for tokensuserinfo_endpoint- Where user data is fetchedrevocation_endpoint- Where tokens are revoked (logout)
Authorization Flow
Standard Login Flow
Token Refresh Flow
The SDK automatically refreshes tokens before they expire:
Logout Flow
Tokens Explained
Access Token
Purpose: Authenticate API requests
Lifetime: Short (typically 15 minutes)
Storage: Stored in browser storage by SDK
Usage: Automatically included in API calls
Refresh Token
Purpose: Get new access tokens without re-login
Lifetime: Long (days to months)
Storage: Stored in browser storage by SDK
Usage: Automatically used by SDK when access token expires
ID Token
Purpose: Contains user identity information (JWT)
Lifetime: Same as access token
Storage: Stored in browser storage by SDK
Usage: SDK validates and decodes for user info
Scopes and Permissions
Scopes define what your application can access. The SDK automatically includes required scopes.
Common Scopes:
OPENID- Required for OIDC authentication
We're constantly adding new features and for those we're adding new scopes as well, so for the latest scopes and what they'll do please refer to the OPENID Configuration mentioned above and look for the key scopes_info.
App Registration
Before using the SDK, register your app on Deva to get credentials:
Sign in to deva.me
Navigate to Settings → Apps
Click Create new app
Provide required information:
App Name: Your application name
Description: Brief description
Redirect URIs: Where Deva redirects after login (e.g.,
http://localhost:3000)Origin URIs: Where your app makes requests from (e.g.,
http://localhost:3000)Scopes: Select required access permissions
Save your
client_id- you'll need this for the SDK
Note: You do not need a client_secret for the SDK. The PKCE flow eliminates the need for secrets in browser applications.
Learn step-by-step how to register your app
Security Best Practices
Implemented by SDK
PKCE Flow: Prevents authorization code interception
State Parameter: Prevents CSRF attacks (handled automatically)
Token Storage: Tokens stored securely in browser storage
Automatic Refresh: Tokens refreshed before expiration
Your Responsibility
HTTPS in Production: Always use HTTPS for production apps
Redirect URI Validation: Ensure redirect URIs are exact matches
Origin Whitelisting: Only whitelist trusted domains
Token Exposure: Never log or expose tokens in console/errors
Related Documentation
Core Concepts:
Authentication Flow - How authentication works
Provider Pattern - Managing auth state
Getting Started:
Quickstart Guide - Get started with the SDK
Deva SSO - Why use Deva authentication
Implementation:
Login Implementation - Add login functionality
Logout Handling - Implement logout functionality
Token Management - Understand token lifecycle
External Resources:
OpenID Connect Specification - Official OIDC documentation
Last updated