Jump to content

Steam Socialite Provider for Laravel


Recommended Posts

  • Game Developer

As the official package Laravel Socialite does not accept new adapters and Extended Socialite Providers maintained by the community does not have an active development anymore and its usage is not straight forward like in the first case, we have decided to create an own package that adds a Socialite adapter for Steam OpenID.

 

You can find the source code on GitHub and view the package on Packagist.

 

Installation

For installation instructions, head over to the Installation part of README.

 

Documentation

As the package uses Laravel Socialite, the usage of the package is exactly same as with different adapters (drivers). Thus, consult the official Laravel documentation.

 

Example

Below is an example of a Laravel controller inspired by the official documentation.

<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Lang;
use Laravel\Socialite\Facades\Socialite;
use Laravel\Socialite\Two\InvalidStateException;

class LoginController extends Controller
{
    /**
     * Redirect the user to the Steam authentication page.
     *
     * @return \Illuminate\Http\Response
     */
    public function redirectToProvider()
    {
        return Socialite::driver('steam')->redirect();
    }

    /**
     * Obtain the user information from Steam.
     *
     * @return \Illuminate\Http\Response
     */
    public function handleProviderCallback()
    {
        try {
            $user = Socialite::driver('steam')->user();

            // $username = $user->getNickname();
        } catch (InvalidStateException $exception) {
            return redirect()->route('login')->with('error', Lang::get('auth.steam.error'));
        }
    }
}

 

Contribution

Any improvements or security vulnerabilities reports are welcome.

  • Like 5

JKTjx3r.jpg

Game Developer

Discord Bot Developer

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.