🔑
Security

OAuth Social Login

Admin Settings

One-click login with Google, GitHub, and more

Overview

Social authentication via OAuth 2.0 providers. Users can link multiple providers to a single account. Seamless registration for new users or linking for existing accounts.

Design Considerations

UX patterns and visual design notes for this feature:

  • •Provider buttons need brand-accurate colors
  • •Show linked accounts in profile settings
  • •Handle "email already exists" gracefully
  • •Loading states during OAuth redirect flow

Key Benefits

What makes this feature stand out:

  • ✓Reduces signup friction dramatically
  • ✓Trusted provider security (Google, GitHub)
  • ✓Multiple providers per account
  • ✓Auto-creates user profile from OAuth data
Technical Note

Uses yiisoft/yii2-authclient. Configure providers in config/web.php authClientCollection. Store tokens in user_oauth table.

Models
UserOauthUser
Database Tables
useruser_oauth

Configuration

Config Relationship Legend
⚙ DB overrides params.php🔗 DB related setting📋 DB stores value only
params.php Configuration

Config path: params['oauth']

params['oauth']['google']['clientId'] => getenv('GOOGLE_CLIENT_ID')params['oauth']['google']['clientSecret'] => getenv('GOOGLE_CLIENT_SECRET')params['oauth']['github']['clientId'] => getenv('GITHUB_CLIENT_ID')
Note: OAuth credentials MUST be stored in .env file, never in database or params.php directly. Configure authClientCollection in config/web.php.