Skip to content

Instantly share code, notes, and snippets.

@AdnanHussainTurki
Created February 14, 2021 22:53
Show Gist options
  • Save AdnanHussainTurki/c837c6b3f7f02e8e156107be1f1aff55 to your computer and use it in GitHub Desktop.
Save AdnanHussainTurki/c837c6b3f7f02e8e156107be1f1aff55 to your computer and use it in GitHub Desktop.
<?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