oauth2-server-php
oauth2-server-php copied to clipboard
The OAuth server will handle granttypes even if it is not added
I create the server without adding any grant type with the 'addGrantType' function, like below:
- a client setup in my database storage, where 'grant_types' set to NULL.
- The OAuth server will just handle requests with 'client_credentials' and 'user_credentials' granttype
- when 'grant_types' set to empty string in database, i.e. '', the server works normally.
// Database storage
$storage = new OAuth2\Pdo([
'dsn' => $dsn,
'username' => $username,
'password' => $password,
]);
// Create OAuth server
$server = new OAuth2\Server($storage);
// Handle incoming requests
$response = $server->handleTokenRequest( OAuth2\Request::createFromGlobals() );
INSERT INTO `oauth_clients` (`client_id`, `client_secret`, `redirect_uri`, `grant_types`, `scope`, `user_id`)
VALUES ('testclient', 'testsecret', NULL, NULL, 'app', NULL);
POST //user/login HTTP/1.1
Host: localhost
Content-Type: application/x-www-form-urlencoded
Content-Length: 75
grant_type=client_credentials&client_id=testclient&client_secret=testsecret