StravaSwift icon indicating copy to clipboard operation
StravaSwift copied to clipboard

ASWeb Auth error due to redirector encoding issue

Open mjunkmyjunk opened this issue 3 years ago • 2 comments

Here is a workaround solution https://stackoverflow.com/a/65092728/14414215 but this also causes issue as there are 2 diff methods of handling the redirectUri depending on if user has the strava app installed on the phone or otherwise.

The percent encoding example (SO link above) is needed if the user does not have the strava app install on the phone. Hence, StravaSwift will fallback to using ASWebAuth.

However, when using this percentEncoding solution, this would then break the authentication callback when the user has the Strava App in the phone. This would then return as "FALSE" once user has fully authenticated in the strava app and returned back to the originating app. (this then breaks the app)

My solution was to do something dumb to this line. https://github.com/mpclarkson/StravaSwift/blob/e6fcffef776e9a36ad16f207b6be954c736a6fe7/Sources/StravaSwift/StravaClient.swift#L148

Basically, replacing the occurrence of the PercentEncoding back to "://" else the comparison (url.absoluteString.starts(with: redirectUri),) fails.

   if let redirectUri = config?.redirectUri.components(separatedBy: "%3A%2F%2F").joined(separator: "://"), url.absoluteString.starts(with: redirectUri),

mjunkmyjunk avatar Aug 21 '21 17:08 mjunkmyjunk

Encoding should be handled in the wrapper. I opened a PR resolving this issue: https://github.com/mpclarkson/StravaSwift/pull/46

loryhuz avatar Oct 23 '23 13:10 loryhuz

First of all, thanks for StravaClient. I know its a passion project, but it has saved me a ton of time. This PR resolves the issue for me as well. Can we get it merged?

jeffbailey avatar Dec 28 '23 14:12 jeffbailey