使用返回的 ApiGility 隐式令牌的正确方法
Correct Way to use returned ApiGility Implicit Token
我的应用程序通过隐式授权接收访问令牌。现在我正尝试使用此令牌访问内容服务器 RPC 服务。我不是 100% 确定这是否是正确的方法,因为我无法让它工作。
$code = (string) $this->params()->fromQuery('code', null);
$client = new HttpClient(
'http://www.example.com/api/books',
array(
'maxredirects' => 0,
'timeout' => 30
)
);
$client->setMethod('GET');
$client->setHeaders(
[
'Accept' => 'application/json',
'Authorization' => 'Bearer '.$code
]
);
try {
$response = $client->send();
} catch (\Exception $e) {
throw new \Exception($e);
}
这是失败的邮递员示例:
在这个问题中使用了 authorization_code 而不是 access_token 这就是它失败的原因。
我的应用程序通过隐式授权接收访问令牌。现在我正尝试使用此令牌访问内容服务器 RPC 服务。我不是 100% 确定这是否是正确的方法,因为我无法让它工作。
$code = (string) $this->params()->fromQuery('code', null);
$client = new HttpClient(
'http://www.example.com/api/books',
array(
'maxredirects' => 0,
'timeout' => 30
)
);
$client->setMethod('GET');
$client->setHeaders(
[
'Accept' => 'application/json',
'Authorization' => 'Bearer '.$code
]
);
try {
$response = $client->send();
} catch (\Exception $e) {
throw new \Exception($e);
}
这是失败的邮递员示例:
在这个问题中使用了 authorization_code 而不是 access_token 这就是它失败的原因。