Muhammad Yasir Amin

Loading websiteโ€ฆ

More from Muhammad Yasir Amin

Build Along With Me

Practical walkthroughs on Laravel, React, APIs and deployment workflows.

Subscribe on YouTube

Laravel 13 Socialite Login with Slack: Sign in with Slack (OpenID Connect)

๐Ÿ› ๏ธ Laravel Tutorials4 min read

Laravel 13 Socialite Login with Slack: Sign in with Slack (OpenID Connect)

Muhammad Yasir Amin

Muhammad Yasir Amin

Senior Full Stack Engineerโ€ขNov 12, 2026
Laravel 13 Socialite Login with Slack: Sign in with Slack (OpenID Connect)

To add Sign in with Slack to Laravel 13, install Socialite, create a Slack app with the Sign in with Slack (OpenID Connect) feature, put its credentials under the slack-openid key in config/services.php and use Socialite::driver('slack-openid') in a redirect route and a callback route. This guide walks through the setup and a safe callback.

Targets: Laravel 13 (PHP 8.3 to 8.5) and laravel/socialite. The Socialite documentation lists both slack and slack-openid; this article uses slack-openid because it matches Slack's OpenID Connect sign-in. Confirm the driver name against the documentation for your installed version.

Step 1: Install Socialite

Code
composer require laravel/socialite

Step 2: Create the Slack app

  1. Go to the Slack API site and choose Create New App, then From scratch.
  2. Pick a name and the workspace you will use for development.
  3. Open OAuth & Permissions and add your callback URL under Redirect URLs, for example https://your-app.test/auth/slack/callback.
  4. Under the user token scopes, add the OpenID scopes (openid, profile and email).
  5. Copy the Client ID and Client Secret from Basic Information.

Slack requires an HTTPS redirect URL for most setups, so use a local tunnel or a local HTTPS domain such as the one your tool provides. Slack's screens change over time, so follow the labels you see.

Step 3: Add the credentials

Code
SLACK_CLIENT_ID=your-client-id
SLACK_CLIENT_SECRET=your-client-secret
SLACK_REDIRECT_URI=https://your-app.test/auth/slack/callback
JavaScript
'slack-openid' => [
    'client_id' => env('SLACK_CLIENT_ID'),
    'client_secret' => env('SLACK_CLIENT_SECRET'),
    'redirect' => env('SLACK_REDIRECT_URI'),
],

Add the array to config/services.php.

Step 4: Store the Slack ID on users

Code
php artisan make:migration add_slack_id_to_users_table --table=users
JavaScript
public function up(): void
{
    Schema::table('users', function (Blueprint $table) {
        $table->string('slack_id')->nullable()->unique()->after('email');
        $table->string('password')->nullable()->change();
    });
}

public function down(): void
{
    Schema::table('users', function (Blueprint $table) {
        $table->dropColumn('slack_id');
    });
}

Add slack_id to the User model's $fillable array and run php artisan migrate.

Step 5: Create the controller

JavaScript
<?php

namespace App\Http\Controllers;

use App\Models\User;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;
use Laravel\Socialite\Facades\Socialite;
use Throwable;

class SlackAuthController extends Controller
{
    public function redirect(): RedirectResponse
    {
        return Socialite::driver('slack-openid')->redirect();
    }

    public function callback(): RedirectResponse
    {
        try {
            $slackUser = Socialite::driver('slack-openid')->user();
        } catch (Throwable $e) {
            report($e);

            return redirect('/login')->withErrors(['email' => 'Slack sign-in failed. Please try again.']);
        }

        $user = User::updateOrCreate(
            ['slack_id' => $slackUser->getId()],
            [
                'name' => $slackUser->getName() ?: 'Slack user',
                'email' => $slackUser->getEmail(),
                'email_verified_at' => now(),
                'password' => Str::password(32),
            ]
        );

        Auth::login($user, remember: true);

        return redirect()->intended('/dashboard');
    }
}

Step 6: Add the routes and the button

CSS
use App\Http\Controllers\SlackAuthController;
use Illuminate\Support\Facades\Route;

Route::get('/auth/slack/redirect', [SlackAuthController::class, 'redirect'])->name('slack.redirect');
Route::get('/auth/slack/callback', [SlackAuthController::class, 'callback']);
HTML / XML
<a href="{{ route('slack.redirect') }}">Sign in with Slack</a>

Should I limit sign-in to one Slack workspace?

If the app is for your team only, check the workspace of the returned user before logging in, or use Slack's team parameter when redirecting. Without such a check, any Slack user can sign in and get an account in your application. Decide who is allowed and enforce it in the callback.

How do I test it?

  1. Open the app over the HTTPS URL that you registered.
  2. Click the Slack button and allow access.
  3. Confirm you reach /dashboard and see the new user with a slack_id.

Common mistakes

  • Wrong driver name: the services key and the driver name must match (slack-openid in this article).
  • HTTP redirect URL: Slack may reject it. Use HTTPS.
  • Missing OpenID scopes: without openid, profile and email the user data is incomplete.
  • Allowing everyone: restrict sign-in if the app is internal.
  • Cached config: run php artisan config:clear after changes.

FAQ

What is the difference between slack and slack-openid?

The slack-openid driver uses Slack's OpenID Connect sign-in, while slack is the older sign-in flow. Prefer the OpenID driver for new projects and check Slack's current guidance.

Can I post messages to Slack from Laravel too?

Yes, but that is a different feature: use incoming webhooks or the Slack notification channel.

Do I need a paid Slack plan?

No. Creating an app and using Sign in with Slack works on a free workspace.

References

Article Index & Topic Tags
LaravelSocialiteAuthenticationSlack

YouTube Channel

Build Along With Me

Practical walkthroughs on Laravel, React, APIs and deployment workflows.

Muhammad Yasir Amin
Available for Contracts
Author & Solutions Architect

Senior Full Stack Engineer

Independent Senior Full Stack Engineer working on Laravel, React and Next.js applications, APIs and delivery workflows.

Laravel & PHP ApplicationsReact & Next.js InterfacesREST APIs & IntegrationsDatabase Queries & DebuggingDocker Development WorkflowsClear Scope & Handover
Discuss Your Next Step

What Does Your Application Need Next?

Share your current system, the problem you want to solve and what a useful result looks like. We can identify the right starting point and agree on a practical scope.

Technical Audit

Find the Next Useful Fix

Application Development

Scoped, Reviewable Milestones

Ongoing Support

Agreed Capacity and Priorities

Share your goals, current stack and requirements before the call.