PHP code example of socialiteproviders / microsoft-azure
1. Go to this page and download the library: Download socialiteproviders/microsoft-azure 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/ */
socialiteproviders / microsoft-azure example snippets
public function logout(Request $request)
{
Auth::guard()->logout();
$request->session()->flush();
$azureLogoutUrl = Socialite::driver('azure')->getLogoutUrl(route('login'));
return redirect($azureLogoutUrl);
}
/**
* Returns a custom config for this specific Azure AD connection / directory
* @return \SocialiteProviders\Manager\Config
*/
function getConfig(): \SocialiteProviders\Manager\Config
{
return new \SocialiteProviders\Manager\Config(
env('AD_CLIENT_ID', 'some-client-id'), // a different clientID for this separate Azure directory
env('AD_CLIENT_SECRET'), // a different secret for this separate Azure directory
url(env('AD_REDIRECT_PATH', '/azuread/callback')), // the redirect path i.e. a different callback to the other azureAD callbacks
['tenant' => env('AD_TENANT_ID', 'common')], // this could be something special if need be, but can also be left out entirely
);
}
//....//
Socialite::driver('azure')
->setConfig(getConfig())
->redirect();