e4se/laravel-telegram-oidc

OpenID Telegram Connect OAuth2 Provider for Laravel Socialite

Maintainers

Package info

github.com/e4se/laravel-telegram-oidc

pkg:composer/e4se/laravel-telegram-oidc

Statistics

Installs: 19

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-03-03 19:19 UTC

This package is auto-updated.

Last update: 2026-03-31 20:48:37 UTC


README

Laravel Support: v9, v10, v11, v12 PHP Support: 8.1, 8.2, 8.3

Installation & Basic Usage

composer require e4se/laravel-telegram-oidc

Please see the Base Installation Guide, then follow the provider specific instructions below.

Add configuration to config/services.php

'telegram-oidc' => [
    'client_id' => env('TELEGRAM_OIDC_CLIENT_ID'),
    'client_secret' => env('TELEGRAM_OIDC_CLIENT_SECRET'),
    'redirect' => env('TELEGRAM_OIDC_REDIRECT_URI')
],

Add provider event listener

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

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.

Event::listen(function (\SocialiteProviders\Manager\SocialiteWasCalled $event) {
    $event->extendSocialite('telegram-oidc', \SocialiteProviders\TelegramOIDC\Provider::class);
});

Laravel 10 or below

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

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

Usage

You should now be able to use the provider like you would regularly use Socialite (assuming you have the facade installed):

return Socialite::driver('telegram-oidc')->redirect();

Returned User fields

  • id
  • name
  • nickname
  • avatar

More fields are available under the user subkey:

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

$phone_number = $user->user['phone_number'];

Customizing the scopes

You may extend the default scopes (openid profile) by adding a scopes option to your OIDC service configuration and separate multiple scopes with a space:

'telegram-oidc' => [
    'client_id' => env('TELEGRAM_OIDC_CLIENT_ID'),
    'client_secret' => env('TELEGRAM_OIDC_CLIENT_SECRET'),
    'redirect' => env('TELEGRAM_OIDC_REDIRECT_URI'),
    
    'scopes' => 'phone',
    // or
    'scopes' => env('TELEGRAM_OIDC_SCOPES'),
],

Based on the work of Kovah