Open stestrepo opened 9 years ago
Post your code in server.php here. I'm guessing you forgot to include the autoloader file.
<?php
$dsn = 'mysql:dbname=oauth_db;host=localhost'; $username = 'sayalig'; $password = '234';
// error reporting (this is a demo, after all!) ini_set('display_errors',1);error_reporting(E_ALL);
// Autoloading (composer is preferred, but for this example let's just do this) require_once('C:\xampp\htdocs\OAuth2\Autoloader.php'); OAuth2\Autoloader::register();
// $dsn is the Data Source Name for your database, for exmaple "mysql:dbname=my_oauth2_db;host=localhost" $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);
// 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));
?>
Can u tell me from while file is authorization code to be passed to whom (eg i'm passing it after the user approves of client accessing its resources with server.) is it right ???
@soauth I cannot understand your question, but the second part sounds right (you pass the code to the token.php
endpoint after the user approves the client).
does the file C:\xampp\htdocs\OAuth2\Controller\ResourceControllerInterface.php exist on your machine?
yes
Oh, it's because you're on a windows machine, and the directory separators are different.
We can either correct this in a pull request, or you can run composer.phar install
and then include __DIR__.'\..\vendor\autoload.php
instead.
(where __dir__.'\..\
points to the root of your project)
I've used the sample lib from server-docs-php
C:>curl -u testclient:testpass http://localhost/OAuth2/token.php -d 'grant_type =authorization_code'
Fatal error: Interface 'OAuth2\Controller\ResourceControllerInterface' n ot found in C:\xampp\htdocs\OAuth2\server.php on line 43