This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Exception Received error [{ "message" : "Invalid signature for signature method HMAC-SHA1", "error" : "The request has not been applied because it lacks valid authentication credentials for the target resource." } ]

Former Member
Former Member

Exception

Received error [{ "message" : "Invalid signature for signature method HMAC-SHA1", "error" : "The request has not been applied because it lacks valid authentication credentials for the target resource." } ] with status code [401] when retrieving workout . 
how to solve it for garmin traning api 
  • I'm working Garmin Health API Integration. Regarding "Acquire Unauthorized Request Token and Token Secret" API integration, I have followed Signature Base String scenario mentioned on "Garmin Connect OAuth Specification" documment.

    I'm facing issue related "Acquire Unauthorized Request Token and Token Secret" response. I got response as "Invalid signature for signature method HMAC-SHA1".

    Below is my Authorization header:

    {Connection: keep-alive, Content-Type: text/plain, Host: connectapi.garmin.com, Accept: */*, Authorization: OAuth oauth_consumer_key=<consumer_key>, oauth_nonce="wyjoejizhpw", oauth_signature=<signature>, oauth_signature_method="HMAC-SHA1", oauth_timestamp="1612243810", oauth_version="1.0"}

    Can you provide me solution, What is the issue while passing Authorization header values. So i will get "oauth_token" & "oauth_token_secret" values in success response.

  • Former Member
    0 Former Member over 3 years ago

    I am getting a 401 while hitting 

    https://connectapi.garmin.com/oauth-service/oauth/access_token which is to get the access token 
    m passing headers like:
    {"Authorization": "OAuth oauth_consumer_key=<key>, oauth_nonce=\"u0USacSShJztIhhLOF10kRceyqRANqLW\", oauth_signature=\"ES%2BkZW%2BbgtGV9FBBxSjAr1V51QU%3D\", oauth_signature_method=\"HMAC-SHA1\", oauth_timestamp=\"1648204317\", oauth_token=\"24187c4c-81c0-4485-899b-5ae3768b6698\", oauth_verifier=\"r5TN0THkDV\", oauth_version=\"1.0\""}
    can someone help me with what's wrong here?
  • I've managed to get this working after quite a bit of trial and error and actually going into researching HMAC-SHA1 and what it does.

    Most likely what's going on is that you are not correctly hashing the URL with the appropriate tokens. That was my issue anyway. Since there are 2 URLs (request and access), you will need to write up code that handles both of them, as separate URLs requiring separate tokens.

    I have a working solution for this on Gumroad for anyone interested. Cheers!

  • In my case I was getting this message but the problem was not authentication. I added  'Content-Type': 'application/json' to the headers and escaped the json payload of the request body, and it worked.