我正在使用以下代码,我正在成功生成访问令牌,但无法获得刷新令牌
$dsn = 'mysql:dbname=my_oauth2_db;host=localhost';
$username = 'root';
$password = '';
// 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('vendor/autoload.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, array(
'always_issue_new_refresh_token' => true,
'refresh_token_lifetime' => 2419200));
// Add the "Client Credentials" grant type (it is the simplest of the grant types)
$server->addGrantType(new OAuth2\GrantType\UserCredentials($storage));
$server->addGrantType(new OAuth2\GrantType\AuthorizationCode($storage));
$server->addGrantType(new OAuth2\GrantType\ClientCredentials($storage));
$server->addGrantType(new OAuth2\GrantType\RefreshToken($storage));
$resp = $server->handleTokenRequest(OAuth2\Request::createFromGlobals())->send();
echo "<pre>";
print_r($resp);
echo "</pre>";
我通过下面的curl请求调用上面的代码
<?php
$username = "testclient";
$password = "testpass";
$url = "http://localhost/oauth2/demo.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
"grant_type=client_credentials&username=bshaffer&password=brent123");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$output = curl_exec($ch);
echo "<pre>";
print_r($output);
echo "</pre>";
我收到了访问令牌的响应,但我希望获得带有上述请求的刷新令牌
{ “的access_token”: “9816b82d6f711a6137b10624a60f2a69fd94e83c”, “expires_in”:3600, “token_type”: “承载”, “范围”:空}
oauth2.0的源链接是https://bshaffer.github.io/oauth2-server-php-docs/grant-types/refresh-token/
任何人都可以帮助解决这个问题 . 谢谢