PHP code example of mattcollins171 / osm-socialite-provider

1. Go to this page and download the library: Download mattcollins171/osm-socialite-provider 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/ */

    

mattcollins171 / osm-socialite-provider example snippets


'cognito' => [
    'host' => env('COGNITO_HOST'),
    'client_id' => env('COGNITO_CLIENT_ID'),
    'client_secret' => env('COGNITO_CLIENT_SECRET'),
    'redirect' => env('COGNITO_CALLBACK_URL'),
    'scope' => explode(",", env('COGNITO_LOGIN_SCOPE')),
    'logout_uri' => env('COGNITO_SIGN_OUT_URL')
],

protected $listen = [
    \SocialiteProviders\Manager\SocialiteWasCalled::class => [
        // ... other providers
        \SocialiteProviders\Cognito\CognitoExtendSocialite::class.'@handle',
    ],
];

return Socialite::driver('cognito')->redirect();

public function cognitoLogout() {
    Auth::logout(); // Log out app
    return redirect(Socialite::driver('cognito')->logoutCognitoUser()); // Call cognito logout url
}

public function cognitoSwitchAccount() {
    Auth::logout(); // Log out app
    $scopes = explode(",", env('COGNITO_LOGIN_SCOPE')); // Override default scopes if needed
    return redirect(Socialite::driver('cognito')->scopes($scopes)->switchCognitoUser()); // Call cognito logout url
}

COGNITO_HOST=https://your-app.auth.ap-southeast-2.amazoncognito.com
COGNITO_CLIENT_ID=abc123
COGNITO_CLIENT_SECRET=abc123
COGNITO_CALLBACK_URL=https://your-app.ngrok.io/oauth2/callback
COGNITO_SIGN_OUT_URL=https://example.com
COGNITO_LOGIN_SCOPE="openid,profile"