Using GArmin API for delete a user registration giving error
{ errorMessage: 'Unable to read oAuth header' }
I am using following API :-
https://healthapi.garmin.com/wellness-api/rest/user/registration
My code are as follow:-
restler.get(accessTokenUrl, {
headers: {'Authorization': 'Bearer ACCESS_TOKEN'}
}).on('complete', function(data) {
console.log(data);
cb();
});
I have found following solution to solve this problem:
var backFillUrl = 'https://healthapi.garmin.com/wellness-api/rest/user/registration';
var newoauthTimeStamp = moment().unix();
var parameters = {
oauth_consumer_key: config.garminHealth.consumer_key,
oauth_nonce: oauthNonce,
oauth_signature_method: oauthSignatureMethod,
oauth_timestamp: newoauthTimeStamp,
oauth_token: user.garmin.accessToken,
oauth_version: oauthVersion
};
var newAuthSignature = oauthSignature.generate('GET', backFillUrl, parameters, config.garminHealth.secret_key, user.garmin.accessTokenSecret, {encodeSignature: true});
var OAuthHeader = 'OAuth oauth_version="' + oauthVersion + '", oauth_consumer_key="' + config.garminHealth.consumer_key +
'", oauth_timestamp="' + newoauthTimeStamp + '", oauth_nonce="' + oauthNonce + '", oauth_signature_method="' +
oauthSignatureMethod + '", oauth_signature="' + newAuthSignature + '", oauth_token="' + user.garmin.accessToken + '"';
restler.get(backFillUrl, {
query: {
accessToken: 'ACCESS_TOKEN'
},
headers: {'Authorization': OAuthHeader}
}).on('complete', function (er) {
if(er) return cb(er);
else cb();
});