Convert Figma logo to code with AI

laravel logosocialite

Laravel wrapper around OAuth 1 & OAuth 2 libraries.

5,535
942
5,535
1

Top Related Projects

Open source social sign on PHP Library. HybridAuth goal is to act as an abstract api between your application and various social apis and identities providers such as Facebook, Twitter and Google.

Socialite is an OAuth2 Authentication tool. It is inspired by laravel/socialite, you can easily use it without Laravel.

Easy integration with OAuth 2.0 service providers.

Manage events on a Google Calendar

Quick Overview

Laravel Socialite is an official Laravel package that provides an expressive, fluent interface to OAuth authentication with various social media platforms. It simplifies the process of authenticating users through social providers like Facebook, Twitter, LinkedIn, Google, GitHub, GitLab, and Bitbucket.

Pros

  • Easy integration with Laravel applications
  • Supports multiple popular social media platforms out of the box
  • Consistent API across different providers
  • Extensible to add custom providers

Cons

  • Limited to OAuth-based authentication
  • Requires separate configuration for each provider
  • May require additional setup for certain providers (e.g., creating developer accounts)
  • Potential privacy concerns when relying on third-party authentication

Code Examples

  1. Basic usage with GitHub provider:
use Laravel\Socialite\Facades\Socialite;

return Socialite::driver('github')->redirect();

This code redirects the user to GitHub's OAuth authorization page.

  1. Handling the callback:
$user = Socialite::driver('github')->user();

// $user->token
// $user->id
// $user->name
// $user->email

This code retrieves the authenticated user's information after they are redirected back to your application.

  1. Retrieving user details without authentication:
$user = Socialite::driver('github')->userFromToken($token);

This code fetches user details using an existing OAuth token.

Getting Started

  1. Install Socialite via Composer:

    composer require laravel/socialite
    
  2. Add the service provider to config/app.php:

    'providers' => [
        // Other service providers...
        Laravel\Socialite\SocialiteServiceProvider::class,
    ],
    
  3. Add the Socialite facade to config/app.php:

    'aliases' => [
        // Other facades...
        'Socialite' => Laravel\Socialite\Facades\Socialite::class,
    ],
    
  4. Configure your OAuth credentials in config/services.php:

    'github' => [
        'client_id' => env('GITHUB_CLIENT_ID'),
        'client_secret' => env('GITHUB_CLIENT_SECRET'),
        'redirect' => 'http://your-callback-url',
    ],
    
  5. Use Socialite in your routes or controllers as shown in the code examples above.

Competitor Comparisons

Open source social sign on PHP Library. HybridAuth goal is to act as an abstract api between your application and various social apis and identities providers such as Facebook, Twitter and Google.

Pros of Hybridauth

  • Supports a wider range of social networks and identity providers (60+)
  • Framework-agnostic, can be used with any PHP project
  • More granular control over the authentication process

Cons of Hybridauth

  • Requires more setup and configuration compared to Socialite
  • Less seamless integration with Laravel ecosystem
  • May require more code to implement basic authentication flows

Code Comparison

Socialite:

return Socialite::driver('github')->redirect();

$user = Socialite::driver('github')->user();

Hybridauth:

$hybridauth = new Hybridauth($config);
$adapter = $hybridauth->authenticate('GitHub');
$userProfile = $adapter->getUserProfile();

Summary

Socialite is tailored for Laravel applications, offering a streamlined experience for common social authentication scenarios. It's easy to set up and integrates well with Laravel's ecosystem.

Hybridauth, on the other hand, provides more flexibility and supports a broader range of providers. It's suitable for various PHP projects but may require more initial setup and code for basic authentication flows.

Choose Socialite for quick Laravel integrations with popular providers, or Hybridauth for more complex scenarios, non-Laravel projects, or when working with less common social networks.

Socialite is an OAuth2 Authentication tool. It is inspired by laravel/socialite, you can easily use it without Laravel.

Pros of Socialite (overtrue)

  • Supports a wider range of OAuth providers (100+) compared to Laravel Socialite
  • Includes built-in support for popular Chinese social platforms (e.g., WeChat, Weibo)
  • More flexible and customizable, allowing easier integration of new providers

Cons of Socialite (overtrue)

  • Less tightly integrated with the Laravel ecosystem
  • May require more configuration and setup for basic use cases
  • Documentation is primarily in Chinese, which could be challenging for non-Chinese speakers

Code Comparison

Laravel Socialite:

return Socialite::driver('github')->redirect();

Overtrue Socialite:

$socialite = new SocialiteManager($config);
return $socialite->create('github')->redirect();

Both libraries provide similar functionality, but Overtrue Socialite requires an additional step of creating a SocialiteManager instance. This reflects its more flexible nature, allowing for easier customization and integration of new providers.

While Laravel Socialite is more tightly integrated with the Laravel framework and offers a simpler API for common use cases, Overtrue Socialite provides greater flexibility and support for a wider range of providers, especially those popular in China.

Easy integration with OAuth 2.0 service providers.

Pros of oauth2-client

  • Framework-agnostic, can be used with any PHP project
  • Supports a wider range of OAuth 2.0 providers
  • More granular control over the OAuth 2.0 flow

Cons of oauth2-client

  • Requires more setup and configuration
  • Less integration with Laravel-specific features
  • May require additional packages for specific providers

Code Comparison

oauth2-client:

$provider = new \League\OAuth2\Client\Provider\GenericProvider([
    'clientId'     => 'your-client-id',
    'clientSecret' => 'your-client-secret',
    'redirectUri'  => 'https://example.com/callback-url',
    'urlAuthorize' => 'https://example.com/oauth/authorize',
    'urlAccessToken' => 'https://example.com/oauth/token',
    'urlResourceOwnerDetails' => 'https://example.com/api/user'
]);

Socialite:

return Socialite::driver('github')->redirect();

oauth2-client provides more flexibility but requires more configuration, while Socialite offers a simpler, Laravel-specific implementation with less customization options. oauth2-client is better suited for projects that need to work with multiple frameworks or require fine-grained control over the OAuth process, whereas Socialite is ideal for Laravel applications seeking quick and easy social authentication integration.

Manage events on a Google Calendar

Pros of Laravel Google Calendar

  • Focused specifically on Google Calendar integration, offering more specialized features
  • Provides methods for creating, updating, and deleting events in Google Calendar
  • Simplifies working with Google Calendar API, reducing boilerplate code

Cons of Laravel Google Calendar

  • Limited to Google Calendar functionality, while Socialite supports multiple OAuth providers
  • Requires separate setup for authentication, as it doesn't handle OAuth flow directly
  • May require more frequent updates to stay compatible with Google Calendar API changes

Code Comparison

Laravel Google Calendar:

use Spatie\GoogleCalendar\Event;

$event = new Event;
$event->name = 'Meeting';
$event->startDateTime = Carbon::now();
$event->endDateTime = Carbon::now()->addHour();
$event->save();

Socialite:

use Laravel\Socialite\Facades\Socialite;

return Socialite::driver('google')
    ->scopes(['https://www.googleapis.com/auth/calendar'])
    ->redirect();

While Socialite focuses on OAuth authentication for various providers, Laravel Google Calendar offers specific methods for interacting with Google Calendar. Socialite provides a more general OAuth solution, whereas Laravel Google Calendar simplifies working directly with calendar events and data.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Logo Laravel Socialite

Build Status Total Downloads Latest Stable Version License

Introduction

Laravel Socialite provides an expressive, fluent interface to OAuth authentication with Facebook, Twitter, Google, LinkedIn, GitHub, GitLab and Bitbucket. It handles almost all of the boilerplate social authentication code you are dreading writing.

We are not accepting new adapters.

Adapters for other platforms are listed at the community driven Socialite Providers website.

Official Documentation

Documentation for Socialite can be found on the Laravel website.

Contributing

Thank you for considering contributing to Socialite! The contribution guide can be found in the Laravel documentation.

Code of Conduct

In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

License

Laravel Socialite is open-sourced software licensed under the MIT license.