PHPackages                             trwl/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. trwl/socialite-mastodon

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

trwl/socialite-mastodon
=======================

Socialite for Mastodon

1.2.4(6y ago)050.4k↓25%MITPHPPHP &gt;=7.0.0

Since Apr 13Pushed 3y agoCompare

[ Source](https://github.com/HerrLevin/socialite-mastodon)[ Packagist](https://packagist.org/packages/trwl/socialite-mastodon)[ RSS](/packages/trwl-socialite-mastodon/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (16)Used By (0)

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

[](#socialite-for-mastodon)

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'),
        //'read', 'write', 'follow'
        'scope'         => ['read'],
    ],

```

### .env

[](#env)

```
MASTODON_DOMAIN=https://mastodon.social
MASTODON_ID=
MASTODON_SECRET=
MASTODON_REDIRECT=https://example.com/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@index');
Route::get('callback', 'MastodonController@callback');

```

MastodonController

```
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use 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

```
    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('my-app', 'https://example.com/callback', 'read');

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

        //change config
        config(['services.mastodon.domain' => $domain]);
        config(['services.mastodon.client_id' => $server->client_id]);
        config(['services.mastodon.client_secret' => $server->client_secret]);

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

        return Socialite::driver('mastodon')->redirect();
    }

    public function callback()
    {
        $domain = session('mastodon_domain');
        $server = session('mastodon_server');

        config(['services.mastodon.domain' => $domain]);
        config(['services.mastodon.client_id' => $server->client_id]);
        config(['services.mastodon.client_secret' => $server->client_secret]);

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

LICENCE
-------

[](#licence)

MIT

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 82.6% 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 ~64 days

Recently: every ~125 days

Total

15

Last Release

2429d ago

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

1.2.0PHP &gt;=7.0.0.

1.2.2PHP &gt;=7.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/ac58b3aec3dadbf487c45d852e5df107a3d350812f47dc7e658f8abefd68c4a1?d=identicon)[HerrLevin\_](/maintainers/HerrLevin_)

---

Top Contributors

[![kawax](https://avatars.githubusercontent.com/u/1502086?v=4)](https://github.com/kawax "kawax (19 commits)")[![HerrLevin](https://avatars.githubusercontent.com/u/1267894?v=4)](https://github.com/HerrLevin "HerrLevin (4 commits)")

---

Tags

laravelsocialitemastodon

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[socialiteproviders/manager

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

42542.0M544](/packages/socialiteproviders-manager)[andrewdwallo/filament-companies

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

34450.0k2](/packages/andrewdwallo-filament-companies)[revolution/socialite-mastodon

Socialite for Mastodon

13203.2k1](/packages/revolution-socialite-mastodon)[chrisreedio/socialment

Provides Socialite functionality for Filament.

10884.8k1](/packages/chrisreedio-socialment)[schedula/laravel-passport-socialite

The missing laravel passport feature for social authentication

4822.6k](/packages/schedula-laravel-passport-socialite)[truckersmp/steam-socialite

Laravel Socialite provider for Steam OpenID.

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

PHPackages © 2026

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