/usr/share/accounts/qml-plugins/fitbit/Main.qml is in account-plugin-fitbit 4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | import Ubuntu.OnlineAccounts.Plugin 1.0
import "js/oauth.js" as Oauth
OAuthMain {
creationComponent: OAuth {
function completeCreation(reply) {
var token = []
token['token'] = reply.AccessToken;
token['tokenSecret'] = reply.oauth_token_secret;
token['encoded_user_id'] = reply.encoded_user_id;
token['consumerKey'] = "e47deba61e904c469392040aee772092";
token['consumerSecret'] = "a5ae28cb96854344834e7174b881d88d";
call_fitbit(reply, token)
}
function call_fitbit(reply, token) {
var message = {method: "GET", action: "http://api.fitbit.com/1/user/-/profile.json", parameters: {}}
var apikey = "de27c24cb9be4fe9b25364e6ec6a34c8"
var fitbit_url = "http://api.fitbit.com/1/user/-/profile.json"
var tok = {"token": reply.AccessToken, "consumerKey": "e47deba61e904c469392040aee772092", }
console.log("Access token: " + reply.AccessToken)
Oauth.OAuth.completeRequest(message, tok);
Oauth.OAuth.setParameter(message, "oauth_signature_method", "PLAINTEXT")
Oauth.OAuth.SignatureMethod.sign(message, token, {});
var headers = Oauth.OAuth.getAuthorizationHeader("api.fitbit.com", message.parameters);
var http = new XMLHttpRequest()
http.open("GET", fitbit_url, true);
http.onreadystatechange = function() {
if (http.readyState === 4){
if (http.status == 200) {
console.log("response text: " + http.responseText)
var response = JSON.parse(http.responseText)
account.updateDisplayName(response['user']['displayName'])
globalAccountService.updateSettings({
'id': response['user']['displayName']
})
account.synced.connect(finished)
account.sync()
// return response['user']['displayName']
} else {
console.log("error: " + http.status)
cancel()
}
}
};
http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
http.setRequestHeader('Authorization', headers)
http.send(null);
}
}
}
|