Steam OpenID Authentication on Laravel
You need to use Laravel Steam Auth
Very easy setup:
Composer install
"invisnik/laravel-steam-auth": "2.*"
Add the service provider to app/config/app.php, within the providers array.
'providers' => [ Invisnik\LaravelSteamAuth\SteamServiceProvider::class,]
- Publish config:
php artisan vendor:publish
- Setup your route and API key in
config/steam-auth.php
- Add route:
Route::get('dologin', 'Auth\SteamController@dologin');
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
Composer Install
// This assumes that you have composer installed globallycomposer require socialiteproviders/steam
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 ];
Add the event and listeners
protected $listen = [ \SocialiteProviders\Manager\SocialiteWasCalled::class => [ // add your listeners (aka providers) here 'SocialiteProviders\Steam\SteamExtendSocialite@handle', ],];
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.