-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth.php
41 lines (33 loc) · 1.06 KB
/
auth.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace O365Integration;
require 'vendor/autoload.php';
// require 'config.php';
use TheNetworg\OAuth2\Client\Provider\Azure;
class O365Auth {
private $provider;
public function __construct() {
$this->provider = new Azure([
'clientId' => Config::CLIENT_ID,
'clientSecret' => Config::CLIENT_SECRET,
'redirectUri' => Config::REDIRECT_URI,
'tenant' => Config::TENANT_ID,
'defaultEndPointVersion' => '2.0'
]);
$this->provider->defaultEndPointVersion = '2.0';
}
public function getAuthorizationUrl() {
return $this->provider->getAuthorizationUrl([
'scope' => Config::SCOPES
]);
}
public function getAccessToken($code) {
return $this->provider->getAccessToken('authorization_code', [
'code' => $code
]);
}
public function refreshToken($refreshToken) {
return $this->provider->getAccessToken('refresh_token', [
'refresh_token' => $refreshToken
]);
}
}