PHP code example of laravel-fans / socialite-providers

1. Go to this page and download the library: Download laravel-fans/socialite-providers library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

laravel-fans / socialite-providers example snippets


return [
    'providers' => [
        /*
         * Package Service Providers...
         */
        // remove 'Laravel\Socialite\SocialiteServiceProvider',
        \SocialiteProviders\Manager\ServiceProvider::class,
    ]
];

use LaravelFans\SocialiteProviders\Coding\CodingExtendSocialite;
use LaravelFans\SocialiteProviders\WeChatWeb\WeChatWebExtendSocialite;
use SocialiteProviders\Manager\SocialiteWasCalled;

class EventServiceProvider extends ServiceProvider
{
    protected $listen = [
        Registered::class => [
            SendEmailVerificationNotification::class,
        ],
        SocialiteWasCalled::class => [
            // add your listeners (aka providers) here
            CodingExtendSocialite::class,
            WeChatWebExtendSocialite::class,
        ],
    ];
}

return [
    'coding' => [
        'client_id' => env('CODING_CLIENT_ID'),
        'client_secret' => env('CODING_CLIENT_SECRET'),
        'redirect' => env('CODING_CALLBACK_URL'),
        'guzzle' => [
            'base_uri' => 'https://' . env('CODING_TEAM') . '.coding.net/',
        ],
        'scopes' => preg_split('/,/', env('CODING_SCOPES'), null, PREG_SPLIT_NO_EMPTY), // optional, can not use explode, see vlucas/phpdotenv#175
    ],
];

return Socialite::with('coding')->redirect();

// to turn off stateless
return Socialite::with('coding')->stateless(false)->redirect();

// to use stateless
return Socialite::with('coding')->stateless()->redirect();

$clientId = "foo";
$clientSecret = "bar";
$redirectUrl = "http://127.0.0.1:8000/login/coding/callback";
$additionalProviderConfig = [
    // Add additional configuration values here.
    'guzzle' => [
        'base_uri' => 'https://your-team.coding.net/',
    ],
];
$config = new \SocialiteProviders\Manager\Config(
    $clientId,
    $clientSecret,
    $redirectUrl,
    $additionalProviderConfig
);

return Socialite::with('coding')->setConfig($config)->redirect();

$user = Socialite::driver('coding')->user();
$accessTokenResponseBody = $user->accessTokenResponseBody;