I ran into this issue trying to create a small sandbox using OAuth2 at work. I'm using the bones of the Getting Started code:
$storage = new OAuth2\Storage\Pdo(array('dsn' => $dsn, 'username' => $username, 'password' => $password));
// Pass a storage object or array of storage objects to the OAuth2 server class
$server = new OAuth2\Server(
$storage,
[
'allow_implicit' => true,
'use_openid_connect' => true,
'always_issue_new_refresh_token' => true,
'issuer' => $_SERVER['HTTP_HOST']
]
);
// Add the "Client Credentials" grant type (it is the simplest of the grant types)
$server->addGrantType(new OAuth2\GrantType\ClientCredentials($storage));
// Add the "Authorization Code" grant type (this is where the oauth magic happens)
$server->addGrantType(new OAuth2\GrantType\AuthorizationCode($storage));
$server->addGrantType(new OAuth2\GrantType\RefreshToken($storage, [
'always_issue_new_refresh_token' => true
]));
$server->addStorage($storage, 'public_key');
$request = OAuth2\Request::createFromGlobals();
$response = new OAuth2\Response();
$response = $server->handleAuthorizeRequest($request, $response, true);
Using the default Pdo class yields the following error.
Incorrect syntax near the keyword 'IS'.' in D:\home\site\wwwroot\vendor\bshaffer\oauth2-server-php\src\OAuth2\Storage\Pdo.php:619
The query is SELECT private_key FROM dbo.oauth_public_keys WHERE client_id='SOME_CLIENT_ID' OR client_id IS NULL ORDER BY client_id IS NOT NULL DESC and I was able to solve it by removing IS NOT NULL
I ran into this issue trying to create a small sandbox using OAuth2 at work. I'm using the bones of the Getting Started code:
Using the default Pdo class yields the following error.
The query is
SELECT private_key FROM dbo.oauth_public_keys WHERE client_id='SOME_CLIENT_ID' OR client_id IS NULL ORDER BY client_id IS NOT NULL DESC
and I was able to solve it by removingIS NOT NULL
https://github.com/bshaffer/oauth2-server-php/blob/061f81496dbe52fc0514c1642b366eac1b125310/src/OAuth2/Storage/Pdo.php#L617