我按照这个步骤操作,但执行此操作时:
curl -u testclient:testpass http://localhost/token.php -d 'grant_type=client_credentials'
收到此
{"error":"invalid_request,"error_description":"The grant type was not specified in the request"}
在这种情况下,如何将'grant_type'放入请求中
这是两个文件 server.php
$dsn = 'mysql:dbname=oauth2;host=localhost';
$username = 'root';
$password = '';
// error reporting (this is a demo, after all!)
ini_set('display_errors',1);error_reporting(E_ALL);
require_once('../src/OAuth2/Autoloader.php');
OAuth2\Autoloader::register();
$storage = new OAuth2\Storage\Pdo(array('dsn' => $dsn, 'username' => $username, 'password' => $password));
$server = new OAuth2\Server($storage);
$server->addGrantType(new OAuth2\GrantType\AuthorizationCode($storage)); // or any grant type you like!
token.php
require_once __DIR__.'/server.php';
// Handle a request for an OAuth2.0 Access Token and send the response to the client
$server->handleTokenRequest(OAuth2\Request::createFromGlobals())->send();
答案 0 :(得分:0)
这是两个文件 server.php
$dsn = 'mysql:dbname=oauth2;host=localhost';
$username = 'root';
$password = '';
// error reporting (this is a demo, after all!)
ini_set('display_errors',1);error_reporting(E_ALL);
require_once('../src/OAuth2/Autoloader.php');
OAuth2\Autoloader::register();
$storage = new OAuth2\Storage\Pdo(array('dsn' => $dsn, 'username' => $username, 'password' => $password));
$server = new OAuth2\Server($storage);
$server->addGrantType(new OAuth2\GrantType\AuthorizationCode($storage)); // or any grant type you like!
token.php
require_once __DIR__.'/server.php';
// Handle a request for an OAuth2.0 Access Token and send the response to the client
$server->handleTokenRequest(OAuth2\Request::createFromGlobals())->send();
答案 1 :(得分:0)
试试这个:
curl -u testclient:testpass http://localhost/token.php -d grant_type = client_credentials