๐Ÿ‘จโ€๐Ÿ’ป
Socialstream
  • Introduction
  • โฎ๏ธPrologue
    • Release Notes
    • Upgrade Guide
      • Upgrading to v6 from 5.x
      • Upgrading to v5 from 4.x
      • Upgrading to v4 from 3.x
      • Upgrading to v3 from 2.x
      • Upgrading to v2 from 1.x
    • Contribution Guide
  • ๐Ÿ”‘Getting Started
    • Installation
    • Configuration
    • Customization
      • Socialite Redirect
      • Resolving Users
      • Handling Invalid State
      • Handling OAuth Errors
      • Authenticating Users
  • ๐Ÿš€Features
    • Remember Session
    • Refresh Expired Tokens
    • Provider Avatars
    • Global Login
    • Register from Login
    • Missing Emails
    • Auth Existing Unlinked Users
    • Login on Registration (deprecated)
  • ๐Ÿงพguides
    • Standalone Installation
    • Filament with Jetstream
    • Filament with Breeze
    • Laravel Passport
    • Socialite Providers
    • Overriding Fortify's Authentication
  • ๐Ÿ”—Links
    • View Code On GitHub
    • About Me
    • Contribute
    • Donate
Powered by GitBook
On this page
  • Installation
  • Setup
  • Icons
  • Config
  • Socialstream Providers
  • Service Provider
  • Add provider event listener
  • Database Changes โ€“ token

Was this helpful?

  1. guides

Socialite Providers

The aim of this guide is to walk you through setting up a fresh Laravel project with Jetstream, Socialstream and Socialite Providers.

PreviousLaravel PassportNextOverriding Fortify's Authentication

Last updated 4 months ago

Was this helpful?

If you're unfamiliar with Laravel Socialite, Jetstream or Socialite Providers, we encourage you to read through their documentation before continuing with this guide.


Before we begin, this guide assumes that you have already setup a fresh Laravel project with Socialstream. If this is not the case, check out the Installation instructions for Socialstream.

Installation

To install a socialite provider, you may do so via composer. For example, to add the Apple provider, you may execute the following command in your terminal:

composer require socialiteproviders/apple

Setup

Icons

First, we need to create an SVG icon or custom button component for the provider within your desired stack. You will then need to update the published components for your stack to cater for this provider:

Livewire

Icon location: resources/views/components/socialstream-icons/

  • resources/views/components/socialstream.blade.php

  • resources/views/components/connected-account.blade.php

Inertia

Icon location: resources/js/Components/SocialstreamIcons/

  • resources/js/Components/Socialstream.vue

  • resources/js/Components/ConnectedAccount.vue

Config

Socialstream Providers

Inside your applications socialstream.php config file, you will want to add the string representation of the SocialiteProvider you are adding support for. For example, if you are adding Sign in With Apple support, you would add the string 'apple' to the providers array in config/socialstream.php

'providers' => [
    \JoelButcher\Socialstream\Providers::github(),
    \JoelButcher\Socialstream\Providers::google(),
    [
        'id' => 'apple',
        'name' => 'Apple',
        'label' => 'Sign in with Apple',
    ],
],

Service Provider

Laravel 11+

In bootstrap/providers.php.

return [
    // a whole bunch of providers
    // remove 'Laravel\Socialite\SocialiteServiceProvider',
    \SocialiteProviders\Manager\ServiceProvider::class, // add
];

In Laravel 10 or Below

In config\app.php.

'providers' => [
    // a whole bunch of providers
    // remove 'Laravel\Socialite\SocialiteServiceProvider',
    \SocialiteProviders\Manager\ServiceProvider::class, // add
];

Add provider event listener

Laravel 11+

In Laravel 11, the default EventServiceProvider provider was removed. Instead, add the listener using the listen method on the Event facade, in your AppServiceProvider boot method.

  • Note: You do not need to add anything for the built-in socialite providers unless you override them with your own providers.

Event::listen(function (\SocialiteProviders\Manager\SocialiteWasCalled $event) {
    $event->extendSocialite('microsoft', \SocialiteProviders\Microsoft\Provider::class);
});
Laravel 10 or below

Configure the package's listener to listen for SocialiteWasCalled events.

protected $listen = [
    \SocialiteProviders\Manager\SocialiteWasCalled::class => [
        // ... other providers
        \SocialiteProviders\Microsoft\MicrosoftExtendSocialite::class.'@handle',
    ],
];

Database Changes โ€“ token

Some providers will not return a token in the callback response. As such, you will need to modify the connected_accounts table migration to make the token field nullable:

$table->string('token', 1000)->nullable();

Add the event to your listen[] array in app/Providers/EventServiceProvider. See the for detailed instructions.

๐Ÿงพ
Laravel Socialite
Laravel Jetstream
Socialite Providers
Base Installation Guide