Auth0 token not working in fitbit web api

I logged in successfully with auth0 using social login with Fitbit , but now I need to call fitbit api and its asking me for brearer access token , I got access token and id token from auth0 and tried in fitbit web api but fitbit api not working and giving error like invalide token.

How can I get fitbit access token from auth0 ?
I am developing android app and using WebAuthProvider for fitbit login.

Thank you

Hey there!

I guess as you say you have id and access token and still receiving an error I would reach out to Fitbit Community Forum or open a support request to ask them where the issue is coming from in their platform.

Thank you for your reply but I need quick solution and my client is waiting.

Its kind request that solved it as soon as possible.

I would really love to help you but we are not supposed to be recommending anything in terms of stack that we donā€™t have expertise on (here Fitbit API). We actually donā€™t kno where the issue is coming from. Can you share any screenshots, error logs etc?

you providing access token and id token when successfully logged in , those are auth0 token or fitbit token ? do you know about that ?

What do you use to get those tokens?

WebAuthProvider.login(auth0)
.withScheme(ā€œdemoā€)
.withAudience(String.format(ā€œhttps://%s/userinfoā€, getString(R.string.com_auth0_domain)))
.withScope(ā€œopenid profile email offline_access read:current_user update:current_user_metadataā€)
.start(this, new AuthCallback() {
@Override
public void onFailure(@NonNull final Dialog dialog) {
runOnUiThread(new Runnable() {
@Override
public void run() {
dialog.show();
}
});
}

                @Override
                public void onFailure(final AuthenticationException exception) {
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            Toast.makeText(LoginActivity.this, "Error: " + exception.getMessage(), Toast.LENGTH_SHORT).show();
                        }
                    });
                }

                @Override
                public void onSuccess(@NonNull final Credentials credentials) {
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {

                            token =credentials.getAccessToken();

                            credentialsManager.saveCredentials(credentials);

                            Log.e("token ",credentials.getIdToken());

                        }
                    });

                }
            });

this above code using for fitbit login
its gave me idtoken and I am using that for fitbit web api

fitbit api url
https://api.fitbit.com/1/user/8Q3RDK/profile.json
and passing header with idtoken which auth0 providing

after calling above url , its giving me error

{ā€œsuccessā€:false,ā€œerrorsā€:[{ā€œerrorTypeā€:ā€œinvalid_tokenā€,ā€œmessageā€:ā€œAccess token invalid: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik5jVTB3NUQtZ2o1WVN3VjVQNWpabSJ9.eyJuaWNrbmFtZSI6InNhbmpheSBtLiIsIm5hbWUiOiJzYW5qYXkgbS4iLCJwaWN0dXJlIjoiaHR0cHM6Ly9zdGF0aWMwLmZpdGJpdC5jb20vaW1hZ2VzL3Byb2ZpbGUvZGVmYXVsdFByb2ZpbGVfMTAwLnBuZyIsImdlbmRlciI6Ik1BTEUiLCJsb2NhbGUiOiJlbi1JTiIsInVwZGF0ZWRfYXQiOiIyMDIwLTA4LTAzVDEyOjM0OjIzLjg1OVoiLCJpc3MiOiJodHRwczovL2Rldi01Mnpsbzgzdi51cy5hdXRoMC5jb20vIiwic3ViIjoiZml0Yml0fDhRM1JESyIsImF1ZCI6InEzdkRXamMxY1IydXlsTEczMFNTektwYldGRlVyazJoIiwiaWF0IjoxNTk2NTQwMzYzLCJleHAiOjE1OTY1NzYzNjMsIm5vbmNlIjoiUDlvVXZqTXU1bDhiMjlfM2JmeVBRODhqTENCT2dSTjFZY09MWHktXzNrYyJ9.nvCO5NhhwM8WuOsm75R3H7aDxJzXkfeH5nVWM5s0kx6olXQN4OHWRqQC6ZEPvjNF7Hk1eqL3J0RSPNe2qC5qqH1Uzgy95GnDqDwjQtnBSGSTopYB1mM9EAwiZgflnc-eJ2Zkhc1A3zhmKgzNfzfBuDpP6LRbrkO93n5Ad-j7RCYQyDbKIoRGhI8adUpX2lsmTE9Omv7RMg2ehJhYI6r4VBl-RWqL31jklOam1ZNt8Q-P5puXCVK16hN1ZtDIBNuGEWvVPf4g4Plp7GXWBNYQc_ShIZgMNROsmXpBhraDSYNS-XhUAbveZ0qiYLu2uCVXVX_s9bQnTRORG4P1fQMk8g. Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process.ā€}]}

Not sure where the issue is coming from. Can you share that with Fitbit support so they can say where the issue is potentially coming from?

I would also suggest checking this FAQ:

I am trying in fitbit and will be back to you.

ok perfect! thanks for letting me know!

1 Like

I know this thread is quite old, but I think the issue is that you need to use the identity provider access_token provided by Fitbit rather than the Auth0 access_token for your app.

As a note, itā€™s quite difficult to come across that page in the Auth0 docs. The article which explains how to connect an app to Fitbit makes no mention of actually calling the Fitbit API from a connected app.

https://auth0.com/docs/connections/social/fitbit

Donā€™t know if this is the right place to make suggestions, but if any Auth0 people read this, it would be really useful to have the ā€˜Call an Identity Provider APIā€™ page linked in the ā€˜Next Stepsā€™ section of articles which explain how to set up social connections.

1 Like

Iā€™ll pass that feedback to our docs team!