我正在测试一个简单的oauth curl php脚本,但它不断返回此错误
回调网址上的代码:
$code = $_GET['code'];
$url = "https://www.linkedin.com/uas/oauth2/accessToken";
$redirect_uri = "http://127.0.0.1:8080/auth.php";
$api_key = "78v5tds9n6u10x";
$secret_key = "XXXXXXX";
$tokenArguments = array("grant_type" => "authorization_code",
"code" => $code,
"redirect_uri" => $redirect_uri,
"client_secret" => $secret_key,
"client_id" => $api_key);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $tokenArguments);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
print_r($result);
我在添加内容类型标题之前收到错误,即使添加它也会出现相同的错误。
{"error_description":"missing required parameters, includes an invalid parameter value, parameter more than once. : client_id","error":"invalid_request"}
答案 0 :(得分:1)
尝试这种方式我通过创建SHA
的过程得到了我的解决方案try {
PackageInfo info = context.getPackageManager().getPackageInfo(
packageName, PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
// writtenToFile("FB_KEY_HASH.txt",
// Base64.encodeToString(md.digest(),
// Base64.DEFAULT).toString(), false);
if (AppUtills.showLogs)
Log.v(pageName,
"KeyHash:"
+ Base64.encodeToString(md.digest(),
Base64.DEFAULT));
}
} catch (Exception e) {
e.printStackTrace();
}