Yandex ID Authentication for Website

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1212
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    852
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    815

Yandex ID Authentication Implementation for Websites

Yandex ID is Yandex's authorization system. Relevant for Russian audiences—many users have Yandex.Mail, and login via it reduces registration friction. Implemented via OAuth2 with OpenID Connect support.

Registering Application

  1. oauth.yandex.ru → Create application
  2. Specify name, type—Web services
  3. Add Callback URI: https://example.com/auth/yandex/callback
  4. In Access section add: Yandex ID (email, username, avatar)
  5. Save ClientID and Client secret

Laravel Socialite

composer require laravel/socialite socialiteproviders/yandex
// config/services.php
'yandex' => [
    'client_id'     => env('YANDEX_CLIENT_ID'),
    'client_secret' => env('YANDEX_CLIENT_SECRET'),
    'redirect'      => env('YANDEX_REDIRECT_URI'),
],

class YandexAuthController extends Controller
{
    public function redirect(): RedirectResponse
    {
        return Socialite::driver('yandex')->redirect();
    }

    public function callback(): RedirectResponse
    {
        try {
            $yandexUser = Socialite::driver('yandex')->user();
        } catch (\Exception $e) {
            return redirect('/login')->withErrors(['yandex' => 'Yandex authorization error']);
        }

        $user = User::updateOrCreate(
            ['yandex_id' => $yandexUser->getId()],
            [
                'name'              => $yandexUser->getName(),
                'email'             => $yandexUser->getEmail(),
                'email_verified_at' => now(),
                'avatar'            => $yandexUser->getAvatar(),
            ]
        );

        Auth::login($user, remember: true);
        return redirect()->intended('/dashboard');
    }
}

Getting Data via Yandex ID API

Beyond OAuth callback, request data directly via API:

$response = Http::withToken($accessToken)
    ->get('https://login.yandex.ru/info', ['format' => 'json']);

$data = $response->json();
// $data['id']           — unique ID
// $data['login']        — login
// $data['default_email']— primary email
// $data['real_name']    — name
// $data['display_name'] — display name
// $data['default_avatar_id'] — avatar ID

Yandex Avatar follows template:

https://avatars.yandex.net/get-yapic/{avatar_id}/islands-200

Sizes: islands-50, islands-100, islands-200.

Linking with Existing Account

$user = User::where('yandex_id', $yandexUser->getId())->first()
    ?? User::where('email', $yandexUser->getEmail())->first();

if ($user && !$user->yandex_id) {
    $user->update(['yandex_id' => $yandexUser->getId()]);
} elseif (!$user) {
    $user = User::create([
        'yandex_id'         => $yandexUser->getId(),
        'name'              => $yandexUser->getName(),
        'email'             => $yandexUser->getEmail(),
        'email_verified_at' => now(),
    ]);
}

Timeline

Standard OAuth2 flow—1–2 days.