Steam OpenID Authentication on Laravel Steam OpenID Authentication on Laravel laravel laravel

Steam OpenID Authentication on Laravel


You need to use Laravel Steam Auth

Very easy setup:

  1. Composer install

    "invisnik/laravel-steam-auth": "2.*"

  2. Add the service provider to app/config/app.php, within the providers array.

    'providers' => [ Invisnik\LaravelSteamAuth\SteamServiceProvider::class,]

  3. Publish config: php artisan vendor:publish
  4. Setup your route and API key in config/steam-auth.php
  5. Add route: Route::get('dologin', 'Auth\SteamController@dologin');
  6. Use this live code example, as code from readme not worked for me:

        <?php    public function dologin(Request $request)    {        if ($this->steam->validate()) {             $info = $this->steam->getUserInfo();            if (! is_null($info)) {                $user = User::where('token', $info->get('steamID64'))->first();                if (! is_null($user)) {                    //Update user data, as it change over time..                    $user->nick = $info->get('personaname');                    $user->name = $info->get('realname') ?: '';                    $user->avatar = $info->get('avatarfull');                    $user->update();                } else {                    $user = User::create([                        'nick' => $info->get('personaname'),                        'name' => $info->get('realname') ?: '',                        'avatar' => $info->get('avatarfull'),                        'token'  => $info->get('steamID64'),                    ]);                                    }                Auth::login($user, true);                return redirect('/'); // redirect to site            }        }         return $this->steam->redirect(); // redirect to Steam login page    }


Socialite Steam Login

  1. Composer Install

    // This assumes that you have composer installed globallycomposer require socialiteproviders/steam
  2. SERVICE PROVIDER

    • Remove Laravel\Socialite\SocialiteServiceProvider from your providers[] array in config\app.php if you have added it already.

    • Add \SocialiteProviders\Manager\ServiceProvider::class to your providers[] array in config\app.php.

      'providers' => [  // a whole bunch of providers  // remove 'Laravel\Socialite\SocialiteServiceProvider',  \SocialiteProviders\Manager\ServiceProvider::class, // add ];
  3. Add the event and listeners

    protected $listen = [  \SocialiteProviders\Manager\SocialiteWasCalled::class => [  // add your listeners (aka providers) here  'SocialiteProviders\Steam\SteamExtendSocialite@handle',  ],];
  4. ENVIRONMENT VARIABLES in ,env file

    // other values aboveSTEAM_KEY=yourapikeyfortheserviceSTEAM_REDIRECT_URI=https://example.com/login

sources:- http://socialiteproviders.github.io/providers/steam/

Hopefully, this helps with your steam login.