Created
February 14, 2021 22:53
-
-
Save AdnanHussainTurki/c837c6b3f7f02e8e156107be1f1aff55 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use myPHPnotes\Microsoft\Auth; | |
use myPHPnotes\Microsoft\Handlers\Session; | |
use myPHPnotes\Microsoft\Models\User; | |
session_start(); | |
require "vendor/autoload.php"; | |
$auth = new Auth(Session::get("tenant_id"), Session::get("client_id"), Session::get("client_secret"), Session::get("redirect_uri"), Session::get("scopes")); | |
$tokens = $auth->getToken($_REQUEST['code'], $_REQUEST['state']); | |
$accessToken = $tokens->access_token; | |
$auth->setAccessToken($accessToken); | |
$user = new User; | |
echo "Name: " . $user->data->getDisplayName() . "<br>"; | |
echo "Email: " . $user->data->getUserPrincipalName() . "<br>"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment