EdR
EdR

Reputation: 143

Fitbit Authorization with OAuth.io

I'm trying to use OAuth.io to allow users to connect their Fitbit to our application. Right now, I'm trying to see what information I can get from using the out-of-the-box Fitbit configuration using this code:

$scope.connectFitbit = function() {
    OAuth.initialize(OAUTHIO_KEY);
    OAuth.popup('fitbit').done(function(result) {
        console.log(result);
    });
};

I receive a token and token secret in the response, which is great, but I don't know how to get the Fitbit user ID. I will need to store all three of those to make API requests. Documentation is not clear on the next step, so any help would be appreciated!

Including the console output for reference.

Object {oauth_token: "TOKEN", oauth_token_secret: "TOKEN_SECRET", get: function, post: function, put: function…}
    del: function (opts, opts2) {
    get: function (opts, opts2) {
    me: function (filter) {
    oauth_token: "TOKEN"
    oauth_token_secret: "TOKEN_SECRET"
    patch: function (opts, opts2) {
    post: function (opts, opts2) {
    put: function (opts, opts2) {
    __proto__: Object

Upvotes: 1

Views: 239

Answers (1)

EdR
EdR

Reputation: 143

So, despite radio silence here, I slogged on and found out the answer. You need to then make a call to the user profile API, but using the authenticated user method.

Put this inside your done block:

result.get("/1/user/-/profile.json").done(function(data) 
{
    uID = data.user.encodedId;

    // Store uID along with token and secret for future use
}

Upvotes: 2

Related Questions