jhaoda / socialite-odnoklassniki
Odnoklassniki OAuth2 Provider for Laravel Socialite
Installs: 92 589
Dependents: 2
Suggesters: 0
Security: 0
Stars: 41
Watchers: 6
Forks: 14
Open Issues: 1
Requires
- php: ^7.2 || ^8.0
- ext-json: *
- socialiteproviders/manager: ~4.0
README
1. Installation
composer require jhaoda/socialite-odnoklassniki
2. Service Provider
- Remove
Laravel\Socialite\SocialiteServiceProvider
from yourproviders[]
array inconfig\app.php
if you have added it already. - Add
SocialiteProviders\Manager\ServiceProvider
to yourproviders[]
array inconfig\app.php
.
For example:
'providers' => [ // a whole bunch of providers // remove 'Laravel\Socialite\SocialiteServiceProvider', SocialiteProviders\Manager\ServiceProvider::class, // add ];
- Note: If you would like to use the Socialite Facade, you need to install it.
3. Add the Event and Listeners
-
Add
SocialiteProviders\Manager\SocialiteWasCalled::class
event to yourlisten[]
array in<app_name>/Providers/EventServiceProvider
. -
Add your listeners (i.e. the ones from the providers) to the
SocialiteProviders\Manager\SocialiteWasCalled[]
that you just created. -
The listener that you add for this provider is
JhaoDa\SocialiteProviders\Odnoklassniki\OdnoklassnikiExtendSocialite::class
. -
Note: You do not need to add anything for the built-in socialite providers unless you override them with your own providers.
For example:
/** * The event handler mappings for the application. * * @var array */ protected $listen = [ \SocialiteProviders\Manager\SocialiteWasCalled::class => [ \JhaoDa\SocialiteProviders\Odnoklassniki\OdnoklassnikiExtendSocialite::class ], ];
4. Services Array and .env
Add to config/services.php
:
'odnoklassniki' => [ 'client_id' => env('ODNOKLASSNIKI_ID'), 'client_secret' => env('ODNOKLASSNIKI_SECRET'), 'client_public' => env('ODNOKLASSNIKI_PUBLIC'), 'redirect' => env('ODNOKLASSNIKI_REDIRECT'), ],
Append provider values to your .env
file:
Note: Add both public and secret keys!
// other values above
ODNOKLASSNIKI_ID=your_app_id_for_the_service
ODNOKLASSNIKI_PUBLIC=your_app_public_for_the_service
ODNOKLASSNIKI_SECRET=your_app_secret_for_the_service
ODNOKLASSNIKI_REDIRECT=https://example.com/login