我找到了以下解决方案来解决这个问题:
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();
});