-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoken.php
More file actions
42 lines (38 loc) · 939 Bytes
/
Copy pathtoken.php
File metadata and controls
42 lines (38 loc) · 939 Bytes
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
42
<?php
$config = include 'config.php';
if ($config['debug']) {
error_reporting(E_ALL);
ini_set('display_errors', 'On');
} else {
error_reporting(0);
ini_set('display_errors', 'Off');
}
// Register an autoloader for classes.
// The namespace will correspond to folder structure
spl_autoload_register(function ($class)
{
$file = str_replace('\\', '/', $class) . '.php';
if (file_exists($file)) {
include $file;
}
});
use Response\ErrorResponse;
use Grant\ResourceOwnerPasswordCredentialsGrant;
use Grant\RefreshTokenGrant;
use Database\Database;
if (empty($_POST['grant_type'])) {
ErrorResponse::invalidRequest();
} else {
switch ($_POST['grant_type']) {
case 'password':
ResourceOwnerPasswordCredentialsGrant::respond();
break;
case 'refresh_token':
RefreshTokenGrant::respond();
break;
default:
ErrorResponse::unsupportedGrantType($_POST['grant_type']);
break;
}
}
?>