- Can I use Overtrue/Socialite in a Laravel project without the `overtrue/laravel-socialite` wrapper?
- Yes, you can use the base `overtrue/socialite` package directly in Laravel. The wrapper (`overtrue/laravel-socialite`) adds middleware and route helpers, but the core package works standalone. For Laravel-specific features like session handling, the wrapper simplifies integration.
- What Laravel versions does `overtrue/laravel-socialite` support?
- The `overtrue/laravel-socialite` wrapper is designed for Laravel 8.x and 9.x. Check the [wrapper’s GitHub](https://github.com/overtrue/laravel-socialite) for the latest compatibility notes. The core `overtrue/socialite` package requires PHP 8.0.2+ but is framework-agnostic.
- How do I handle token storage securely for production?
- The package doesn’t enforce storage—you must implement a strategy (e.g., encrypted database, Redis) via `TokenRepositoryInterface`. For Laravel, use the wrapper’s built-in session storage or a custom repository. Always encrypt tokens at rest and revoke them on logout or account deletion.
- Does Socialite support Chinese platforms like WeChat or Alipay?
- Yes, it includes out-of-the-box support for WeChat (including component mode), Alipay, DingTalk, and others. Each provider has platform-specific configuration guides in the [README](https://github.com/overtrue/socialite). Validate your app credentials against these docs to avoid auth flow failures.
- How can I mock OAuth2 responses for testing in CI/CD?
- Use provider-specific test accounts (e.g., GitHub’s OAuth test tokens) or mock the `SocialiteManager` with interfaces like `ProviderInterface`. Libraries like `mockery` can simulate responses for unit tests. For integration tests, configure a staging environment with real provider credentials.
- What’s the difference between `overtrue/socialite` and Laravel’s built-in `socialiteproviders/socialite`?
- Laravel’s `socialiteproviders/socialite` is a fork of the original `laravel/socialite` (now deprecated) and is Laravel-specific. `overtrue/socialite` is framework-agnostic, supports more providers (especially Chinese platforms), and follows modern PHP standards (PHP 8.0+). It’s ideal for non-Laravel projects or those needing broader provider support.
- How do I handle refresh tokens for long-lived access?
- The package doesn’t auto-manage refresh tokens, but you can implement logic in your `TokenRepositoryInterface`. Store refresh tokens alongside access tokens and use the provider’s API to exchange them when expired. For Laravel, the wrapper includes helpers to simplify this flow.
- Can I use Socialite in a serverless environment like Cloudflare Workers?
- Yes, the stateless design of OAuth2 and Socialite makes it compatible with serverless. Store tokens in a shared cache (e.g., Redis) or database. For Cloudflare Workers, use the `overtrue/socialite-psr15` middleware to integrate with HTTP handlers. Avoid in-memory storage for tokens.
- What if a provider (e.g., Facebook) changes its OAuth2 API?
- Monitor provider deprecations and update the package or your custom provider implementation. The package’s modular design lets you override provider logic. Use feature flags to isolate changes during transitions. Check the [changelog](https://github.com/overtrue/socialite/releases) for breaking updates.
- How do I link multiple social accounts to a single user profile?
- Design a `social_accounts` table with columns for `user_id`, `provider`, and `provider_user_id`. Use the package’s user data to merge accounts or prompt users to resolve conflicts. For Laravel, the `overtrue/laravel-socialite` wrapper includes helpers for this workflow.