GithubHelp home page GithubHelp logo

dreampowder / strava_flutter Goto Github PK

View Code? Open in Web Editor NEW
37.0 9.0 53.0 683 KB

Flutter package to use Strava v3 API

License: Other

Ruby 1.55% Objective-C 0.02% Dart 95.64% Kotlin 0.07% Swift 0.58% HTML 2.13%
dart flutter strava strava-api strava-oauth oauth2-authentication oauth2

strava_flutter's Introduction

gir# strava_flutter

Dart/flutter package to use Strava API v3

Follow the "new" Authentication process

https://developers.strava.com/docs/authentication/

##Warning: This package is under heavy refactoring, there might be breaking changes in the following updates.

API currently supported:

Authentication

  • authorize
  • deauthorize

Athlete related APIs

  • getLoggedInAthlete
  • updateLoggedInAthlete (scope profile:write)
  • getLoggedInAthleteActivities (not limited)
  • getLoggedInAthleteZones
  • getGearById
  • getStats

Club related APIs

  • getClubById
  • getClubActivitiesById
  • getClubMembersById

Race related APIs

  • getRunningRaces
  • getRunningRaceById

Activity related APIs

  • createActivity
  • uploadActivity (includes getUploadById) Tested on TCX and GPX

To generate TCX you can use the following package https://pub.dev/packages/rw_tcx

Segments related APIs

  • getSegmentById
  • getLoggedInAthleteStarredSegments
  • getLeaderboardBySegmentId (not limited)
  • starSegment

How to install

Check on pub.dev/packages to see how to install this package

https://pub.dev/packages/strava_flutter#-installing-tab-

Additional steps when running on Android Pie 9.0 (API level 28)

The webview returned by the auth process may throw net::ERR_CLEARTEXT_NOT_PERMITTED. In this case add android:usersCleartextTraffic="true" to the AndroidManifest.xml like below:

<application
    ....
    android:usesCleartextTraffic="true"
    ....>

How to use it

1 -Get the client secret in your Strava settings related to your app https://www.strava.com/settings/api with "Authorization Callback Domain" set to "redirect"

2 - Settings of the url scheme for Strava Authentication redirect url a) For Android Add the following lines in your AndroidManifest.xml (in android/app/src/)

 <!-- To get redirect url when using url_launcher   -->
 <intent-filter>
    <action android:name="android.intent.action.VIEW" />  
    <category android:name="android.intent.category.DEFAULT" /> 
    <category android:name="android.intent.category.BROWSABLE" /> 
    <data android:scheme="stravaflutter" android:host="redirect" />    
</intent-filter>

Change android:launchMode="singleTop" to android:launchMode="singleInstance" It is needed to have authentication working with firefox

b) for iOS Add the following lines in your info.plist (in ios/Flutter/Runner/)

<key>CFBundleURLTypes</key>
	<array>
		<dict>
			<key>CFBundleTypeRole</key>
			<string>Editor</string>
			<key>CFBundleURLName</key>
			<string>stravaflutter</string>
			<key>CFBundleURLSchemes</key>
			<array>
				<string>stravaflutter</string>
			</array>
		</dict>
	</array>

Also for launching the Native Strava app for Authenticate

	<key>LSApplicationQueriesSchemes</key>
	<array>
		<string>strava</string>
	</array>

3 - Create a file secret.dart and put in this file: final String secret = "[Your client secret]"; final String clientId = "[Your appID]";

4 - import 'secret.dart' when you need secret and clientId in Strava API

5 - To see debug info in Strava API, set isInDebug to true in Strava() init

6 - Please check examples.dart for the moment

https://github.com/BirdyF/strava_flutter/blob/master/example/lib/main.dart

https://github.com/BirdyF/strava_flutter/blob/master/example/lib/examples.dart

If you have any problem or need an API not yet implemented please post a new issue

Tested on:

  • Android 7, 8.0.0, 9.0, 10
  • iOS 12.1, 13.2, 13.3.1
  • NOT working yet on web (Auth problem, not coming back to initial page)

Contributors welcome!

If you spot a problem/bug or if you consider that the code could be better please post an issue. I am not planning to implement all the Strava APIs, because I dont need all of them in my dev. But let me know if you need some APIs that are not in the current list and I will add it. Alternatively, you can easily implement additional API and I will add it to strava_futter.

Thanks

License:

strava_flutter is provided under a MIT License. Copyright (c) 2019-2020 Patrick FINKELSTEIN

strava_flutter's People

Contributors

ajgreenman avatar anxious-engineer avatar babenlrichards avatar birdyf avatar bwhiteapps avatar chriselliotuk avatar dependabot[bot] avatar dreampowder avatar e385 avatar etabakov avatar fauzipadlaw avatar felipefernandesleandro avatar haslinger avatar iwishiwasaneagle avatar jacek-galla avatar laebrye avatar ludoo0d0a avatar mrcsabatoth avatar nenuphar12 avatar rubberbird avatar withu-william avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

strava_flutter's Issues

401 and Problem in deAuth request

Is this working for you? I can authenticate but getting 401 for all API functions. Also when I try a de-auth I get an error.

flutter: --> Strava_flutter: Problem in deAuthorize request
flutter: --> Strava_flutter: Problem in deAuthorize request

Missing variable assignment

In class RefreshAnswer (token.dart) the value for model.expiresIn isn't assigned:

model.expiresAt = map['expires_in'];
should be
model.expiresIn = map['expires_in'];

Infinite Loop in getLoggedInAthleteActivities

Steps to reproduce:

  1. Create oauth token without the activity:read_all
  2. Call getLoggedInAthleteActivities, parameters don't matter

Expected Behavior:
The method returns an error about insufficient permissions or whatever the Strava API will return.

Actual Behavior:
The method gets in infinite loop. As a result, you really quickly hit the API Rate limit and you cannot use the API for the next 15 minutes.

Take a loot at this loop, it will be ended only if the returned statusCode is 200:
https://github.com/BirdyF/strava_flutter/blob/272f116e708979ef0dabb0c331c3e5d4e5de378c/lib/API/athletes.dart#L191-L233

Unsuccessful deAuthorization might be a deadend

We stumbled upon the following case:

  1. User is authorized
  2. The token of the user becomes invalid for some reason
  3. The User is trying to deauthorize

With the current implementation:
https://github.com/BirdyF/strava_flutter/blob/709b0af68f0e58846178c48c4282ee7bfaf62201/lib/API/Oauth.dart#L410-L423

If there is an error in the deauthorization request, the token is not cleared from the local storage. In this case, the user is stuck because the strava_flutter package will not try to create a new token (as one already exists but is invalid) and deauthorization is not possible.

I will open a PR with my suggestion.

CLEARTEXT_NOT_PERMITTED in callback

First off, a big thanks for creating strava_flutter! I think it's awesome, that you put the work in to create it.

I'am trying to use it in my app following the example as closely as possible.
Auth triggers the opening of Strava's auth page, that looks absolutely fine for my app:

When I click accept, the callback url is https://www.strava.com/oauth/authorize?client_id=38103&redirect_uri=http://localhost:8080&response_type=code&approval_prompt=auto&scope=activity:write,activity:read_all,profile:read_all,profile:write which results in an error shown

Log output in Android Studio looks like this:

Syncing files to device TA 1053...
I/flutter ( 6010): --> Strava_flutter: Welcome to Oauth
I/flutter ( 6010): --> Strava_flutter: Entering getStoredToken
I/flutter ( 6010): --> Strava_flutter:  current time in ms 1565970337.343   exp. time: null
I/flutter ( 6010): --> Strava_flutter: is token expired? false
I/flutter ( 6010): --> Strava_flutter: token has been stored before! null  exp. null
I/flutter ( 6010): --> Strava_flutter: Doing a new authorization
I/flutter ( 6010): --> Strava_flutter: Entering getStravaCode
I/flutter ( 6010): --> Strava_flutter: https://www.strava.com/oauth/authorize?client_id=38103&redirect_uri=http://localhost:8080&response_type=code&approval_prompt=auto&scope=activity:write,activity:read_all,profile:read_all,profile:write
W/ActivityThread( 6010): handleWindowVisibility: no activity for token android.os.BinderProxy@841a9b7
I/WebViewFactory( 6010): Loading com.google.android.webview version 76.0.3809.111 (code 380911135)
I/cr_LibraryLoader( 6010): Time to load native libraries: 2 ms (timestamps 8163-8165)
I/chromium( 6010): [INFO:library_loader_hooks.cc(51)] Chromium logging enabled: level = 0, default verbosity = 0
I/cr_LibraryLoader( 6010): Expected native library version number "76.0.3809.111", actual native library version number "76.0.3809.111"
W/cr_ChildProcLH( 6010): Create a new ChildConnectionAllocator with package name = com.google.android.webview, sandboxed = true
W/matom.encratei( 6010): Accessing hidden method Landroid/content/Context;->bindServiceAsUser(Landroid/content/Intent;Landroid/content/ServiceConnection;ILandroid/os/Handler;Landroid/os/UserHandle;)Z (light greylist, reflection)
I/cr_BrowserStartup( 6010): Initializing chromium process, singleProcess=false
W/matom.encratei( 6010): Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker;-><init>(Landroid/content/Context;I)V (light greylist, reflection)
W/matom.encratei( 6010): Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker;->logEvent(Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;)V (light greylist, reflection)
...

The full source code of the app is over there, probably the only relevant class is StravaFlutterPage in strava_login2.dart. That one is only be a subset of your main.dart.
Btw, final goal of the app is to allow users to analyse their running data on their own phone.

Any hints, what I am doing wrong here are highly appreciated.

startDate and startDateLocal removed from SummaryActivity

Hi,
Thanks for all the work on this package!

Upgrading from v.1.1.0 to 1.2.0 I encountered an issue with startDate and startDateLocal being commented out of the SummaryActivity model.

It looks like it was from the PR relating to #24 where they ended up being commented out but can't see why they would have created an issue. At the moment I'm simply running it as a local package with those lines commented out but would rather use the pub.dev version in pubspec.

Is there an error being thrown by having these fields somewhere else that I'm not aware of? Or is it safe for them to be uncommented?

Get id of club members

Thanks for the package. It helped me bootstrap my app.

My specific use case is to group club activities made by each member of a club. But I see that getClubMembersById() does not include the id of the member. Furthermore, getClubActivitiesById() returns a list of SummaryActivity objects which contain an athlete object but with a null id.

Any suggestion on how I can achieve what I want? I can also start working on a pull request but first I need to know if the Strava API can give me what I want. Maybe I have to be a club administrator to get back the ids of the members?

Conflict with the Strava app

This is most likely not an issue, that could be solved by strava_flutter, but I would like to share my current state of the following issue and ask for your opinions on it:

A user running my app, who has also installed Strava's app on an iPhone (OS Version 13.04), gets the "Authorize to Strava" dialog, but when he clicks on the "Authorize" button, a popup "Open in Strava" appears. By clicking "OK" the Strava app opens and no data is sent back to my app. Cancel repaints the Dialog, so we are in an endless loop. The only way to get the token back into my app is uninstalling the Strava app from the iPhone, run through my app and reinstall the Strava app.

It seems that the Strava app somehow hijacks the request or callback for sending the data back into my app. I would assume, that the Strava app would have to fix that behavior, but my knowledge with iPhone OS is very limited. So maybe that link assignment can be removed by the user on OS level. But I'm not sure. Any ideas or thoughts are appreciated.

Feel free to close this issue, if we can't influence or fix that.

Exception not catched

How do I catch if some error happens?

I have the following code

final stravaClient = StravaClient(secret: '...', clientId: '...');
try {
  final activity = await stravaClient.activities.getActivity(6172408801);
  debugPrint('__________Response: ${activity.name}');
} on Exception catch (e) {
  debugPrint('__________Exception: $e');
} on Error catch (e) {
  debugPrint('__________Error: $e');
}

I'd expect to catch some exception here, as I haven't authenticated yet. None of the debugPrints appear, but this does from the package:

E/flutter (22386): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Instance of 'Fault'
E/flutter (22386): 

.. if I authenticated then I do get back an activity.

Missing 'expires_in' on Token

Missing parameter 'expires_in' on Token

{
"token_type": "Bearer",
"expires_at": 1568775134,
"expires_in": 21600,
"refresh_token": "e5n567567...",
"access_token": "a4b945687g...",
"athlete": {
#{summary athlete representation}
}
}

Strava Authentication page not returning on Android 10

When calling Strava.oauth() on android my app opens a browser and the page displays the following text:

{"message":"Bad Request","errors":[{"resource":"Application","field":"redirect_uri","code":"invalid"}]}

I have the strava app installed, and I added the intent-filter to my AndroidManifest.xml.

I'm running Android 10.

Thanks!

Upgrade shared_preferences dependency to 2.0.0

Hello, first is thank you for providing this package. But it's currently lagging when it comes to the latest packages specifically shared_preferences. And some of the packages I need are dependent on the latest shared_preferences version. Is there a chance you will update your package soon? :)

Flutter Web Authentication Error

Device:

  • MacOS Catalina (10.15.1)
  • Chrome Browser

This is the Service library we've written:

StravaService

import 'package:eat/secret.dart';
import 'package:strava_flutter/Models/detailedAthlete.dart';
import 'package:strava_flutter/Models/stats.dart';
import 'package:strava_flutter/strava.dart';

class StravaService {

  static final Strava _strava = Strava(
      true,
      stravaClientSecret
  );

  static Future<int> getRunMileage() async {
    bool isAuthOk = await _strava.oauth(
        stravaClientId,
        'activity:read_all,profile:read_all',
        stravaClientSecret,
        'auto'
    );
    if (isAuthOk) {
      DetailedAthlete athlete = await _strava.getLoggedInAthlete();
      int aid = athlete.id;
      Stats stats = await _strava.getStats(aid);
      return stats.ytdRunTotals.distance;
    }
    return -1;
  }

}

When the code runs we see the following error in the application tab's console

image

In a new tab the authorization redirect occurs:

image

And in that tabs console we see these errors:

image

_It's worth noting this exact service code works perfect on Mobile after configuring the AndroidManifest.xml & info.plist.

After these errors are thrown the logic fails before the isAuthOk conditional

ActivityType Enum/Class

The addition of an ActivityType Enum or Class of Literals within the library would make filtering activities easier in other contexts within the library.

Strava Activity Types

Proposed Class

class ActivityType {
  static const String AlpineSki = "AlpineSki";
  static const String BackcountrySki = "BackcountrySki";
  static const String Canoeing = "Canoeing";
  static const String Crossfit = "Crossfit";
  static const String EBikeRide = "EBikeRide";
  static const String Elliptical = "Elliptical";
  static const String Golf = "Golf";
  static const String Handcycle = "Handcycle";
  static const String Hike = "Hike";
  static const String IceSkate = "IceSkate";
  static const String InlineSkate = "InlineSkate";
  static const String Kayaking = "Kayaking";
  static const String Kitesurf = "Kitesurf";
  static const String NordicSki = "NordicSki";
  static const String Ride = "Ride";
  static const String RockClimbing = "RockClimbing";
  static const String RollerSki = "RollerSki";
  static const String Rowing = "Rowing";
  static const String Run = "Run";
  static const String Sail = "Sail";
  static const String Skateboard = "Skateboard";
  static const String Snowboard = "Snowboard";
  static const String Snowshoe = "Snowshoe";
  static const String Soccer = "Soccer";
  static const String StairStepper = "StairStepper";
  static const String StandUpPaddling = "StandUpPaddling";
  static const String Surfing = "Surfing";
  static const String Swim = "Swim";
  static const String Velomobile = "Velomobile";
  static const String VirtualRide = "VirtualRide";
  static const String VirtualRun = "VirtualRun";
  static const String Walk = "Walk";
  static const String WeightTraining = "WeightTraining";
  static const String Wheelchair = "Wheelchair";
  static const String Windsurf = "Windsurf";
  static const String Workout = "Workout";
  static const String Yoga = "Yoga";
}

Have a version of uploadActivity which accepts String (XML) or List<int> input instead of file name

When I upload I don't want the file to materialize but I'd like to upload it from memory. In such case I generate the TCX in memory. (Note that I also would like to upload TCX.gz instead of the larger uncompressed TCX. uploadActivity uses http.MultipartFile.fromPath. For in-memory text content there's http.MultipartFile.fromString and for gzip we could use http.MultipartFile.fromBytes. All what needs to be done that this file inclusion statement be factored out to the other two variants and the rest of the function can stay in a core function. This could also help with future tests.

starSegment not working. Wait for Strava to fix it

starSegment is not working for the moment.
Response sent by strava.com is
{"resource"=>"AccessToken", "field"=>"write_permission", "code"=>"missing"} even with the right scope 'profile:write'.
Strava API support explained that this is a problem on their side.
Strava ticket: request (1724)

Error when get package

hello @dreampowder , I'm Using Flutter 2.5.3 (Android SDK version 31.0.0) when I implement this package, I get the error :

Running "flutter pub get" in qoolbike_v1... Because image_picker >=0.8.4 depends on image_picker_platform_interface ^2.3.0 which depends on http ^0.13.0, image_picker >=0.8.4 requires http ^0.13.0. So, because qoolbike_v1 depends on both image_picker ^0.8.4 and http ^0.12.2, version solving failed. pub get failed (1; So, because qoolbike_v1 depends on both image_picker ^0.8.4 and http ^0.12.2, version solving failed.) exit code 1

I would be really grateful for any help
Thank you.

Saving of new access token not awaited?

I see the pattern, that if the access token has expired, the debug log looks like this:

I/flutter (23116): --> Strava_flutter: Welcome to Oauth
I/flutter (23116): --> Strava_flutter: Entering getStoredToken
I/flutter (23116): --> Strava_flutter: stored token ab7ded8cf7d427b598f94889633cd55ff2a55aa3 1581085047 expires: 19/1 8 hours 
I/flutter (23116): --> Strava_flutter:  current time in ms 1581187512.332   exp. time: 1581085047
I/flutter (23116): --> Strava_flutter: is token expired? true
I/flutter (23116): --> Strava_flutter: token has been stored before! ab7ded8cf7d427b598f94889633cd55ff2a55aa3  exp. 1581085047
I/flutter (23116): --> Strava_flutter: Entering getNewAccessToken
I/flutter (23116): --> Strava_flutter: body {"token_type":"Bearer","access_token":"871e5fc0bf071d250953a4b7f74699d227b9c306","expires_at":1581209116,"expires_in":21600,"refresh_token":"d11b107a131f3159356cac46c5581a07cd9556c5"}
I/flutter (23116): --> Strava_flutter: new exp. date: 1581209116
I/flutter (23116): --> Strava_flutter: Entering getLoggedInAthleteActivities
I/flutter (23116): --> Strava_flutter: token saved!!!

and I don't get any new activities. I believe the reason is saving of the token is not await-ed for in
https://github.com/BirdyF/strava_flutter/blob/master/lib/API/Oauth.dart#L247

On the second request everything works fine. That makes me believe it's only that timing issue.

pub.dev entry

Hello @BirdyF , i am about to release a new version in few weeks and i wonder if you can give me publish access from pub.dev, or mark flutter_strava as "discontinued" so i can release with a new one (ofcourse by mentioning you) while keeping pub.dev free from discontinued packages

Upgrade Dependencies

hello, thanks to @dreampowder @BirdyF to make this package, It's very usefull when working with strava API so far, but any plan to upgrade this package, because the Dependencies is too old.
Thanks πŸ‘ πŸ’―

Upload FIT file

can I Upload activity with extension .FIT file from my flutter apps with this package
thanks.

Upgrade intl to 0.17.0

Hello, first is thank you for providing this package. I'm using package intl: ^0.17.0 and error when get package.Can you update your package soon
thank you. :D

Example code with `getEffortsbySegmentId()` runs out Strava API request limit

Problem

I tried to run example code of this lib and when I tapped "Segments" button several times, Strava API started to return an error below.

{"message":"Rate Limit Exceeded","errors":[{"resource":"Application","field":"rate limit","code":"exceeded"}]}

Also, Strava web app shows the number of API requests are extremely high during 15min. (In 2nd graph, the number of requests are around 2500 during 15 min, although I've set up this Strava API just now!!)

γ‚Ήγ‚―γƒͺγƒΌγƒ³γ‚·γƒ§γƒƒγƒˆ 2020-08-15 16 20 42

As debugging result, a do-while loop in SegmentEfforts#getEffortsbySegmentId() seemed to did infinite loop.

Suggestion

If this API will support retry capability, I recommend to have the default "max retry count”. Otherwise, the user of this library may runs out API request limit in very short time unexpectedly, like me.

To have more than one app using strava_flutter in the same phone

We've been developing an app that integrates user Strava data. For development & testing purposes we've set up a couple of flavours.

When performing oauth on any of these flavours, the web page opened up for oauth is inconsistent, but more troubling is that the when selecting Authorize on the strava authorization page, navigation back to the correct app doesn't always happen:

Simulator Screen Shot - iPhone SE (2nd generation) - 2020-09-11 at 14 45 43

As you can see in the screenshot, the flavour that the auth screen has been navigated from is the production flavour of the app, but iOS is trying to open this in the staging flavour. This results in our production flavour hanging because it never receives the result of the oauth. It's not consistent either - sometimes the cancelling the auth and hot restarting the app gets the correct flavour, sometimes it doesn't.

Each of the flavours has its own OS app ID extension and Strava client ID/secret. Each of these are held in our secret file and passed to an app config on launch that is then used for initialising Strava objects and performing oauth throughout the app.

I have run flutter clean and restarted the simulator between each run and this still happens.

This issue is also present on Android, but not as critical as Android presents alternative apps to the user for opening (so the other flavours can be selected if the wrong one is suggested).

I'm guessing that something has to be done with the URL schemes in the info.plist file but I'm at a loss as to what needs to be done. Any help would be much appreciated

Calling Strava().oauth() throws exception.

When I call oauth(), url_launcher's launch() method throws exception:

E/MethodChannel#plugins.flutter.io/url_launcher( 5495): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.mypackage.myapp/io.flutter.plugins.urllauncher.WebViewActivity}; have you declared this activity in your AndroidManifest.xml?

Tried to declare the necessary activity, didn't help. The strange thing is that url_launcher has the required activity in AndroidManifest.xml, so exception should not be thrown.

getActivityById errors when creating DetailedActivity object

When calling getActivityById(id) with a valid Id, I am returned a 200 response but the DetailedActivity.fromJson call errors with an unhandled exception. See stack trace with Strava client in debug mode:

I/flutter ( 4710): --> Strava_flutter: Entering getActivityById
I/flutter ( 4710): --> Strava_flutter: 200
I/flutter ( 4710): --> Strava_flutter: Activity info {"resource_state":3,"athlete":{"id":9999999,"resource_state":1},"name":"Neighborhood Recovery","distance":truncated json....
E/flutter ( 4710): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: type 'double' is not a subtype of type 'int'
E/flutter ( 4710): #0 new DetailedActivity.fromJson package:strava_flutter/Models/activity.dart:198
E/flutter ( 4710): #1 Activities.getActivityById package:strava_flutter/API/activities.dart:34
E/flutter ( 4710): <asynchronous suspension>

It seems like something in the json is resolving as a double and trying to be stored as an int. I will investigate the DetailedActivity coode and comment if I find something but I wanted to get this issue created and visible.

Check authorization

Hi BirdyF,

thank you for your package.

How coud I check the status of authorization without open a new webView if there is no auth?

Thank-you very much,

Roberto

"Request Failed" error on Strava app when I try to authorize

When I load the request url to browser
https://www.strava.com/oauth/mobile/authorize?client_id=73709&redirect_uri=stravaflutter://redirect&response_type=code&approval_prompt=force&scope=read_all
and click Authorize then I get a simple 302, and nothing else

Screenshot_20211103-172453

User Agent Disallowed

Google sign in is throwing the "User agent disallowed" error. Any change we can update user agent and webView to support?

Preference keys should not use generic names

In the current Version 1.09 the Strava token information is stored as pereferencs using names like 'accessToken', 'expire', 'scope', 'refreshToken'.

These names are quite common ones, they can easily interfere with preferences of other libraraies or the ones of the application.

An easy way would of avoiding this would be to prefix the names with a library shortcut.
E.g.: 'strava_accessToken', 'strava_expire', 'strava_scope', 'strava_refreshToken'.

No Such Method Error

HI, Getting this when I am trying out a basic auth.

*[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: NoSuchMethodError: The method '*' was called on null.
Receiver: null
Tried calling: (1000)
#0 Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:50:5)
#1 new DateTime.fromMillisecondsSinceEpoch (dart:core/runtime/libdate_patch.dart:39:36)
#2 _Strava&Object&Upload&Activities&Auth.isTokenExpired (package:strava_flutter/API/Oauth.dart:282:18)
#3 _Strava&Object&Upload&Activities&Auth.oauth (package:strava_flutter/API/Oauth.dart:154:19)

Looks like this was the issue, your comparing to a null string not null itself.

// Check if the token is not expired
    if (_token != "null") {
      globals.displayInfo(
          'token has been stored before! ${tokenStored.accessToken}  exp. ${tokenStored.expiresAt}');

      isExpired = isTokenExpired(tokenStored);
      globals.displayInfo('isExpired $isExpired');
    }

Also had some issues with the urlRefresh URL so I fixed that too.

   var urlRefresh =
        'https://www.strava.com/oauth/token?client_id=${clientID}&client_secret=${secret}&grant_type=refresh_token&refresh_token=${refreshToken}';

And also didn't have url_launcher package which it looks like is required. So I added that.

https://pub.dartlang.org/packages/url_launcher#-installing-tab-

Unable to log in

I have one user who is unable to log in. They click the Connect to Strava button, authorize the app, and the Strava sign-in screen redirects back to the app. However, the sign-in never actually happens. The Strava website does not display my app under "My Apps". The user has Chrome as the default browser. The users phone is a Samsung S9+. Other users have been able to connect to Strava with no problems and I am unable to duplicate the problem. Does anyone have an idea what might be the cause?

uploadActivity 'Token not yet known'

Hello,
I appreciate the work done on this library, and it has worked well for my class project so far.

I encountered this Fault error message today 'Token not yet known', when using uploadActivity(...). I had to change the verification of the header below for it to work. I believe this issue was added in commit 39adf92.

In 'strava_flutter/lib/globals.dart' on line 31-35

      if (_token.accessToken != null) { 
        return {'Authorization': 'Bearer ${_token.accessToken}'}; 
      } else { 
        return {'88': '00'}; 
      }

In 'strava_flutter/lib/API/upload.dart' on line 50-56

var _header = globals.createHeader();

      if (_header.containsKey('88') == false) {
      globals.displayInfo('Token not yet known');
      fault = Fault(error.statusTokenNotKnownYet, 'Token not yet known');
      return fault;
    }

Line 52 should be

if (_header.containsKey('88') == true){

I believe the logic for the other changed statements in commit 39adf92 were correct, I think it was just this one.

Thanks again for creating this package

cannot retrieve new token after expiration

I'm seing a new phenomenon today on an Android device, where the token is expired. Firefox opens, the log shows:

I/flutter (24765): --> Strava_flutter: https://www.strava.com/oauth/authorize?client_id=38103&redirect_uri=stravaflutter://redirect/&response_type=code&approval_prompt=auto&scope=activity:write,activity:read_all,profile:read_all,profile:write
I/flutter (24765): --> Strava_flutter: Running on iOS or Android
Lost connection to device.

And when I confirm in Firefox, the app only shows a white screen. No error message (probably because device connection is lost).
I am developing internal logging into a database anyway right now, so I hope I will be able to get error messages that way. I will investigate further...

Authorization with multiple users

I realize, that this might be an odd use case, but it would be awesome to log out and log in as a different user.

I guess this should be possible right now, by removing the 4 values from prefs and globals for one user, and stick the old ones from the other user in, so feel free to close this issue immediately. But it would be really nice to have it in the api directly.

Can anyone help me implementing the package?

Hi, I have tried multiple times to implement this package in my flutter app, however, after I accept on Strava it never returns to the App. It shows an error saying 'Safari cannot open the page because the address in invalid'... any suggestion of someone who has already implemented this package?

I would be really grateful for any help!!
IMG_6713

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.