PHPackages                             revolution/socialite-mastodon - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. revolution/socialite-mastodon

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

revolution/socialite-mastodon
=============================

Socialite for Mastodon

1.5.3(1y ago)13227.3k↓12.8%2[1 issues](https://github.com/invokable/socialite-mastodon/issues)1MITPHPPHP ^8.0CI passing

Since Apr 13Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/invokable/socialite-mastodon)[ Packagist](https://packagist.org/packages/revolution/socialite-mastodon)[ GitHub Sponsors](https://github.com/invokable)[ RSS](/packages/revolution-socialite-mastodon/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (4)Versions (29)Used By (1)

Socialite for Mastodon
======================

[](#socialite-for-mastodon)

Requirements
------------

[](#requirements)

- PHP &gt;= 8.0

> No version restrictions. It may stop working in future versions.

Install
-------

[](#install)

```
composer require revolution/socialite-mastodon

```

### config/services.php

[](#configservicesphp)

```
    'mastodon' => [
        'domain'        => env('MASTODON_DOMAIN'),
        'client_id'     => env('MASTODON_ID'),
        'client_secret' => env('MASTODON_SECRET'),
        'redirect'      => env('MASTODON_REDIRECT'),
        'scope'         => ['read', 'write'],
    ],
```

### .env

[](#env)

```
MASTODON_DOMAIN=https://localhost
MASTODON_ID=
MASTODON_SECRET=
MASTODON_REDIRECT=https://localhost/callback

```

Create App and get the client\_id &amp; client\_secret
------------------------------------------------------

[](#create-app-and-get-the-client_id--client_secret)

1. Go to your Mastodon's user preferences page.
2. Go to development page.
3. Create new application.
4. Get `Client key` and `Client secret`

Usage
-----

[](#usage)

### Use one instance

[](#use-one-instance)

routes/web.php

```
Route::get('/', [MastodonController::class, 'index']);
Route::get('callback', [MastodonController::class, 'callback']);
```

MastodonController

```
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Laravel\Socialite\Facades\Socialite;

class MastodonController extends Controller
{
    public function index()
    {
        return Socialite::driver('mastodon')->redirect();
    }

    public function callback()
    {
        $user = Socialite::driver('mastodon')->user();
        dd($user);
    }
}
```

Set scopes

```
return Socialite::driver('mastodon')
           ->setScopes(config('services.mastodon.scope', ['read']))
           ->redirect();
```

### Customize domain example

[](#customize-domain-example)

Mastodon API for Laravel

```
use Illuminate\Http\Request;
use Laravel\Socialite\Facades\Socialite;
use Revolution\Mastodon\Facades\Mastodon;
use App\Models\Server;

    public function login(Request $request)
    {
        //input domain by user
        $domain = $request->input('domain');

        //get app info. domain, client_id, client_secret ...
        //Server is Eloquent Model
        $server = Server::where('domain', $domain)->first();

        if (empty($server)) {
            //create new app
            $info = Mastodon::domain($domain)->createApp(client_name: 'my-app', redirect_uris: 'https://example.com/callback', scopes: 'read write');

            //save app info
            $server = Server::create([
                'domain'        => $domain,
                'client_id'     => $info['client_id'],
                'client_secret' => $info['client_secret'],
            ]);
        }

        session(['mastodon_domain' => $domain]);

        return Socialite::driver('mastodon')->with(['domain' => $domain, 'client_id' => $server->client_id])->redirect();
    }

    public function callback()
    {
        $domain = session('mastodon_domain');
        $server = Server::where('domain', $domain)->first();

        $user = Socialite::driver('mastodon')->with(['domain' => $domain, 'client_id' => $server->client_id, 'client_secret' => $server->client_secret])->user();
        dd($user);
    }
```

LICENCE
-------

[](#licence)

MIT

###  Health Score

56

—

FairBetter than 97% of packages

Maintenance70

Regular maintenance activity

Popularity42

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 88.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~114 days

Recently: every ~107 days

Total

27

Last Release

368d ago

PHP version history (6 changes)1.0.0PHP &gt;=5.6.4

1.2.0PHP &gt;=7.0.0.

1.2.2PHP &gt;=7.0.0

1.3.0PHP ^7.2

1.3.2PHP ^7.2||^8.0

1.4.0PHP ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/77618633?v=4)[Revolution](/maintainers/revolution)[@Revolution](https://github.com/Revolution)

---

Top Contributors

[![kawax](https://avatars.githubusercontent.com/u/1502086?v=4)](https://github.com/kawax "kawax (63 commits)")[![danielpetrica](https://avatars.githubusercontent.com/u/4850686?v=4)](https://github.com/danielpetrica "danielpetrica (5 commits)")[![devin-ai-integration[bot]](https://avatars.githubusercontent.com/in/811515?v=4)](https://github.com/devin-ai-integration[bot] "devin-ai-integration[bot] (2 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (1 commits)")

---

Tags

mastodonsocialitelaravelsocialitemastodon

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/revolution-socialite-mastodon/health.svg)

```
[![Health](https://phpackages.com/badges/revolution-socialite-mastodon/health.svg)](https://phpackages.com/packages/revolution-socialite-mastodon)
```

###  Alternatives

[socialiteproviders/manager

Easily add new or override built-in providers in Laravel Socialite.

42645.6M574](/packages/socialiteproviders-manager)[andrewdwallo/filament-companies

A comprehensive Laravel authentication and authorization system designed for Filament, focusing on multi-tenant company management.

34654.9k2](/packages/andrewdwallo-filament-companies)[truckersmp/steam-socialite

Laravel Socialite provider for Steam OpenID.

1517.7k](/packages/truckersmp-steam-socialite)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
