Here am not getting any error, but I didnt get any result from the Google fit. Am trying to getting Google Fit values for third user(example1@gmail.com). User(AuthUser@gmail.com) profile are getting properly and access token valid. But while trying to get the third party user (example1@gmail.com) and Auth user (AuthUser@gmail.com) information it show only {} as result. Any one can help me to get the fitness values from Google Fit.
//oauth2Client.js
getAccessToken(oauth2Client, function() {
// retrieve user profile
plus.people.get({ userId: 'me', auth: oauth2Client }, function(err, profile) {
if (err) {
console.log('An error occured', err);
return;
}
var token;
if(oauth2Client.credentials.refresh_token != null){
token=oauth2Client.credentials.refresh_token;
}
else{
token=oauth2Client.credentials.access_token;
}
fit.users.dataSources.list({'userId':'me','token':token,'email':'example1@gmail.com'}, function(err, result) {
console.log(err); // it returns only null
console.log(result); //it returns only {}
});
console.log(profile.displayName, ':', profile.tagline);
});
});
//fitness.js
list: function(params, callback) {
var parameters = {
options: {
url: 'https://www.googleapis.com/fitness/v1/users/{userId}/dataSources?access_token={token}',
method: 'GET'
},
params: params,
requiredParams: ['userId','token'],
pathParams: ['userId','token'],
context: self
};
return createAPIRequest(parameters, callback);
},
来源:https://stackoverflow.com/questions/35498652/google-fitness-api-returns-only-as-result