1

I want to use HERE map api's in my project.

As per their document, I need to use generate the signature first using Oauth 1.0 HMAC-256.

I am following below AAA sdk by HERE map : https://github.com/heremaps/here-aaa-java-sdk/blob/master/here-oauth-client/src/main/java/com/here/account/auth/SignatureCalculator.java

SignatureCalculator signatureCalculator = new SignatureCalculator(CONSUMER_KEY,CONSUMER_SECRET);
String signature = signatureCalculator.calculateSignature("GET","https://account.api.here.com/oauth2/token",
(System.currentTimeMillis()/1000L),RandomStringUtils.randomAlphanumeric(12), 
SignatureMethod.HMACSHA256,null,null);

But I am not able to generate the token using this signature. I got below error :

{"errorId":"ERROR-25b51579-57d0-4873-b82e-466519b8b6a4","httpStatus":401,"errorCode":401202,"message":"Invalid Client Authorization header, expecting signed request format.","error":"invalid_request","error_description":"errorCode: '401202'. Invalid Client Authorization header, expecting signed request format."}

When i try to do same through postman then everything works perfect. There is difference between both the signature (generated though postman which works / generated though java code)

pw7d5IVYFsYH0zNPNZJU7x3T6LUtDj8zzYw2hsUUlM= . -- Not Working. Generated using AAA here library. tBWyomfDmgihh2kC%2B14qYurOoPF%2FYkpg7QyGpwgZ77A%3D" -- Working Signature , generated through postman

I think I am doing wrong signature generation.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Nagendra Nigade
  • 866
  • 2
  • 12
  • 28

1 Answers1

1

You have to done signature encoding by URLEncoding in UTF-8 format.

URLEncoder.encode("Signature_Generated_from_HMAC-SHA256","UTF-8")
Nimantha
  • 6,405
  • 6
  • 28
  • 69