Reputation: 5452
I am testing a simple oauth curl php script, but it keeps returning this error
the code on the callback url:
$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);
I was getting the error before adding the content-type header, I am still getting the same error even after adding it.
{"error_description":"missing required parameters, includes an invalid parameter value, parameter more than once. : client_id","error":"invalid_request"}
Upvotes: 1
Views: 277
Reputation: 552
Try this way I got my solution with this process of creating 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();
}
Upvotes: 1