Skip to content

Instantly share code, notes, and snippets.

@isvargasmsft
Last active July 10, 2023 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isvargasmsft/12795cf818f0c4a80746804ff44d25b1 to your computer and use it in GitHub Desktop.
Save isvargasmsft/12795cf818f0c4a80746804ff44d25b1 to your computer and use it in GitHub Desktop.
Auth example for PHP SDK 2.0.0-RC5
<?php
// v1.x
$accessToken = getAccessToken(); // custom token retrieval method
$graph = new Graph();
$graph->setAccessToken($accessToken);
$graph ->createRequest('GET', '/me')
->setAccessToken(getAccessToken()) //after initial token expires
...
// v2.0-RC
$tokenRequestContext = new AuthorizationCodeContext(
'tenantId',
'clientId',
'clientSecret',
'authCode',
'redirectUri'
);
$scopes = ['User.Read', 'Mail.Read'];
$authProvider = new PhpLeagueAuthenticationProvider($tokenRequestContext, $scopes);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment