PHP code example of stolfam / ms-azure-sso-php

1. Go to this page and download the library: Download stolfam/ms-azure-sso-php 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/ */

    

stolfam / ms-azure-sso-php example snippets


$code = $_GET['code'];
$state = $_GET['state']; // abc123

// set callback
$client->onAuthSuccess[] = function(UserProfile $userProfile) {
    // authentication successful
    // persist user data where you need
    echo $userProfile->id;
    echo $userProfile->name;
    echo $userProfile->email;
};

if($client->authorize($code)) {
    // success
    // i.e. redirect back to original page before login invoked
}