呃......我不确定我的代码有什么问题。
我参考了oauth2-server的演示。
使用内存存储可以工作但是当我尝试Pdo存储时。
我在位置1处收到“500 Internal Server Error”和“Unexpected character(<)”。
服务器
$storage = new OAuth2\Storage\Pdo(array(
'dsn' => $dsn,
'username' => $username,
'password' => $password));
$this->server = new OAuth2\Server($storage, array(
'use_jwt_access_tokens' => true,
));
$this->server->addGrantType(new OAuth2\GrantType\ClientCredentials($storage));
令牌
public function token_post(){
$this->server->handleTokenRequest(OAuth2\Request::createFromGlobals())->send();
}
我可以通过demo获得access_token,但是这个access_token不起作用。
总是使用资源页面<失败“
资源
public function resource_get()
{
if (!$this->server->verifyResourceRequest(OAuth2\Request::createFromGlobals())) {
exit("Failed");
}
echo json_encode(array('success' => true, 'message' => 'You accessed my APIs!'));
}
我不知道JWT Access Tokens和JWT Bearer之间的区别是什么?
抱歉英语不好。
我使用Google'translation来帮助我完成这些工作。 所以我不能使用真正正确的描述。
再次抱歉英语不好。