gcappon / fitbitter

A Flutter package to make your life easier when dealing with Fitbit APIs.
https://gcappon.github.io/fitbitter/
BSD 3-Clause "New" or "Revised" License
19 stars 21 forks source link

Error refreshToken #14

Closed thunq96 closed 1 year ago

thunq96 commented 1 year ago

I call refreshToken with param like this:

final newCredentials = await FitbitConnector.refreshToken(
        clientID: FitbitHelper.clientID,
        clientSecret: FitbitHelper.clientSecret,
        fitbitCredentials: fitbitCredentials);

but response return error : https://user-images.githubusercontent.com/104921630/221084353-86881669-76c9-4b28-9b65-5dc047625449.png can you help me check it.

gcappon commented 1 year ago

I call refreshToken with param like this:

final newCredentials = await FitbitConnector.refreshToken(
        clientID: FitbitHelper.clientID,
        clientSecret: FitbitHelper.clientSecret,
        fitbitCredentials: fitbitCredentials);

but response return error : https://user-images.githubusercontent.com/104921630/221084353-86881669-76c9-4b28-9b65-5dc047625449.png can you help me check it.

I think there is something wrong with the management of async calls since I see there is an asyncronous suspension going on.

gcappon commented 1 year ago

Is this plugin, any useful for writing data to Fitbit id. Because I have followed all the steps, as mentioned in the document. Registered the application on Fitbit portal, provided with Client ID, Client Secret and Redirected URl. But I am not able to get the credentials, neither I am able to establish any connection between by Application and fitbitter I believe. I need help on this and I cannot even find any reference.

fitbitter is not currently able to write data to Fitbit. Anyway, establishing a connection and getting data are both working.

Zingworks-Sachin commented 1 year ago

What should be the valid format of "callbackUrlScheme" parameter? I am getting the following error:- "Invalid argument (callbackUrlScheme): must be a valid URL scheme"

gcappon commented 1 year ago

Hi! If during the app registration you set the callback url to something like "example://fitbit/auth", then your callbackUrlScheme is "example".

Zingworks-Sachin commented 1 year ago

@gcappon Thanks for your quick response. Will try and update. Thanks

Zingworks-Sachin commented 1 year ago

@gcappon Is there way to define scope i.e. (For e.g just grant access to weight data and do not show other parameters like temperature, sleep etc on Fitbit auth page)?

gcappon commented 1 year ago

Currenlty there is not. The only way to do it right now is to fork the repo and modify manually the url at line 57 of lib/src/urls/fitbitAuthAPIURL.dart which is defining the scopes.

Zingworks-Sachin commented 1 year ago

@gcappon Ok will check. Thanks

thunq96 commented 1 year ago

@gcappon I getAccessToken this code.

Future<String?> getAccessToken() async {
    final currentFitbit = await getCurrentFitbit();
    if (currentFitbit == null) {
      return null;
    }
    final fitbitCredentials = currentFitbit.fitbitCredentials;
    final isTokenValid = await FitbitConnector.isTokenValid(
        fitbitCredentials: fitbitCredentials);
    if (isTokenValid) {
      return currentFitbit.accessToken;
    } else {
      final newFitbitModel = await refreshToken();
      return newFitbitModel?.accessToken;
    }
  }

but I get respons Screenshot 2023-04-04 at 10 09 39 e

thunq96 commented 1 year ago

I want call syncall data, I getAccessToken first, but in step check Token valid I see an error on function and my app was stopped because it couldn't pass await

gcappon commented 1 year ago

I want call syncall data, I getAccessToken first, but in step check Token valid I see an error on function and my app was stopped because it couldn't pass await

Are you awaiting? It seems not.