oauth 访问令牌授权 header 当 POST
oauth access token by authorization header when POST
是否可以通过 header (POST) 接收访问令牌,就像 DELETE 时一样:
Authorization : Bearer 08712391237918273192873token
而不是:
{
access_token : 08712391237918273192873token
}
我的服务器实现是:
$storage = new OAuth2\Storage\Pdo(array(myconfig));
$server = new OAuth2\Server($storage, array(
'always_issue_new_refresh_token' => true,
'refresh_token_lifetime' => 2419200,
));
$server->addGrantType(new OAuth2\GrantType\ClientCredentials($storage));
$server->addGrantType(new OAuth2\GrantType\AuthorizationCode($storage));
$server->addGrantType(new OAuth2\GrantType\RefreshToken($storage));
if (!$server->verifyResourceRequest(OAuth2\Request::createFromGlobals())) {
$server->getResponse()->send();
exit;
}
是的,正如您在 https://github.com/bshaffer/oauth2-server-php/blob/develop/src/OAuth2/TokenType/Bearer.php#L63 的代码中所见,服务器将尝试从 header、查询参数或 post body(按此顺序),它将确保一次只使用其中一种方法。
是否可以通过 header (POST) 接收访问令牌,就像 DELETE 时一样:
Authorization : Bearer 08712391237918273192873token
而不是:
{
access_token : 08712391237918273192873token
}
我的服务器实现是:
$storage = new OAuth2\Storage\Pdo(array(myconfig));
$server = new OAuth2\Server($storage, array(
'always_issue_new_refresh_token' => true,
'refresh_token_lifetime' => 2419200,
));
$server->addGrantType(new OAuth2\GrantType\ClientCredentials($storage));
$server->addGrantType(new OAuth2\GrantType\AuthorizationCode($storage));
$server->addGrantType(new OAuth2\GrantType\RefreshToken($storage));
if (!$server->verifyResourceRequest(OAuth2\Request::createFromGlobals())) {
$server->getResponse()->send();
exit;
}
是的,正如您在 https://github.com/bshaffer/oauth2-server-php/blob/develop/src/OAuth2/TokenType/Bearer.php#L63 的代码中所见,服务器将尝试从 header、查询参数或 post body(按此顺序),它将确保一次只使用其中一种方法。