dreampowder / strava_flutter

Flutter package to use Strava v3 API
Other
37 stars 52 forks source link

Example does not redirect back #81

Closed haslinger closed 2 years ago

haslinger commented 2 years ago

I tried to update my project to latest strava_flutter (from github) and the integration is really a pleasure. But I have i problem: After I confirm on the authorization screen from Strava, I no longer get redirected. On Chrome, there is a short flicker (maybe a redirect to itself), on Firefox the browser switches to a white page with a link "You are being redirected". That link targets stravaflutter://redirect?state=&code=aLongHexCode&scope=read,activity:read_all,profile:read_all,read_al I am testing on a tablet, and a phone, both running Android 11.

I reread the docs here, they don't seem to have changed, especially double checked the <intent filter> part. I am developing using

Flutter 2.10.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision db747aa133 (3 weeks ago) • 2022-02-09 13:57:35 -0600
Engine • revision ab46186b24
Tools • Dart 2.16.1 • DevTools 2.9.2

So I thought, I better check differences to the example you provide. And I am seing the same behaviour in the example (so no need to look into my app yet - which is open source, so just for reference: Encrateia ). As soon as I insert my credentials via secret.dart all analysis errors vanish, but starting let's assembleDebug fails. Reason: path_provider needs a newer SDK version

[   +1 ms] One or more plugins require a higher Android SDK version.
[   +6 ms] Fix this issue by adding the following to /daten/DATA/flutter/strava_flutter/example/android/app/build.gradle:
[        ] android {
[        ]   compileSdkVersion 31

So I change compileSdkVersion and targetSdkVersion to 31. Then compiling fails again, this time with

  ┌─ Flutter Fix 
 [!] Your project requires a newer version of the Kotlin Gradle plugin.                   
Find the latest version on https://kotlinlang.org/docs/gradle.html#plugin-and-versions, then
update /daten/DATA/flutter/strava_flutter/example/android/build.gradle:                   
ext.kotlin_version = '<latest-version>'                                                     

The link provided in the error message shows Kotlin Version 1.6.10, so I set this. (1.3.50 is in the repo code). Then compilation succeeds, the app starts, but the behaviour is as described above: The redirect back is not working.

I guess the changes have something to do with the upgrade of the compileSdKVersion and/or the Kotlin version. Any help appreciated. Here is a fork of the repo showing the current state of my attempt to get the example running.

P.S: A big thank you for the work you are putting into this library! :heart:

abhinandanpro9 commented 2 years ago

@haslinger I was stuck here too. After a bit of research on how redirects works I figured it out. Just add below lines in AndroidManifest.xml

      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      <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>

Also this : On Strava API make sure "Authorization Callback Domain" set to "redirect"

haslinger commented 2 years ago

@abhinandanbr Thank you so much for pointing this out to me, I had the extra line

<data android:pathPattern="/.*" />

in that broke it in my app. Leaving this issue open, as this line should also be removed from the README, I guess?

abhinandanpro9 commented 2 years ago

@abhinandanbr Thank you so much for pointing this out to me, I had the extra line

<data android:pathPattern="/.*" />

in that broke it in my app. Leaving this issue open, as this line should also be removed from the README, I guess?

@haslinger You are welcome. Yup. That's the culprit! Needs to be removed.

dreampowder commented 2 years ago

thanks a lot for your feedback. removed that line from documentation