OAuth2 未指定授权类型

OAuth2 The grant type was not specified

我按照这个步骤,但是当执行这个时:

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();

这是两个文件 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();

试试这个:

curl -u testclient:testpass http://localhost/token.php -d grant_type=client_credentials