I have successfully obtained my hERE MAP API signature.
Now Am working with Here Map API to generate token. source link here is the request payload
POST /oauth2/token HTTP/1.1
Host: account.api.here.com
Authorization: OAuth oauth_consumer_key="1tqA_sample1fLhs2z6_q1l",oauth_signature_method="HMAC-SHA256",oauth_timestamp="1512072698",oauth_nonce="ZGAaMP",oauth_version="1.0",oauth_signature="Q0sample4lqICrx19%2F4ahaH%2Fi2O0NgqDUQJgti5U3Q%3D"
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials
I have implemented the code below but it throws error mismatch. Authorization signature or client credential is wrong
here is the code
$url2="https://account.api.here.com/oauth2/token";
$ch2 = curl_init();
curl_setopt($ch2,CURLOPT_URL, $url2);
//$post_add = "grant_type=client_credentials";
$post_add=array('grant_type'=> 'client_credentials');
$access_key_id ="my keys goes here";
$timer = time();
curl_setopt($ch2, CURLOPT_HTTPHEADER, array(
"Host: account.api.here.com",
"Cache-Control: no-cache",
"Authorization: OAuth oauth_consumer_key='$access_key_id',oauth_signature_method='HMAC-SHA256',oauth_timestamp='$timer',oauth_nonce='ccZGAaMP',oauth_version='1.0',oauth_signature='my signature goes here'",
'Content-Type: application/x-www-form-urlencoded'
));
curl_setopt($ch2,CURLOPT_CUSTOMREQUEST,'POST');
//curl_setopt($ch2,CURLOPT_CUSTOMREQUEST,'DELETE');
curl_setopt($ch2,CURLOPT_POSTFIELDS, $post_add);
curl_setopt($ch2,CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($ch2,CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($ch2,CURLOPT_RETURNTRANSFER, true);
$response2 = curl_exec($ch2);
curl_close($ch2);
print_r($response2);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…