From 8b546daeaa052fcdbf062f4d206679e91831eb82 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 24 Jan 2023 20:43:56 -0500 Subject: [PATCH] Workaround for issues signing in to m.s --- .../Screens/Onboarding/OnboardingViewController.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Tusker/Screens/Onboarding/OnboardingViewController.swift b/Tusker/Screens/Onboarding/OnboardingViewController.swift index 980553d1..7d39dd86 100644 --- a/Tusker/Screens/Onboarding/OnboardingViewController.swift +++ b/Tusker/Screens/Onboarding/OnboardingViewController.swift @@ -51,14 +51,25 @@ class OnboardingViewController: UINavigationController { do { (clientID, clientSecret) = try await mastodonController.registerApp() self.clientInfo = (instanceURL, clientID, clientSecret) + // m.s has problems with (I think) the read replicas not updating fast enough + // so give it some more time to propagate, and prevent invalid_client/etc. errors + if instanceURL.host == "mastodon.social" { + try await Task.sleep(nanoseconds: 2 * NSEC_PER_SEC) + } } catch { throw Error.registeringApp(error) } } let authCode = try await getAuthorizationCode(instanceURL: instanceURL, clientID: clientID) + if instanceURL.host == "mastodon.social" { + try await Task.sleep(nanoseconds: 2 * NSEC_PER_SEC) + } let accessToken: String do { accessToken = try await mastodonController.authorize(authorizationCode: authCode) + if instanceURL.host == "mastodon.social" { + try await Task.sleep(nanoseconds: 2 * NSEC_PER_SEC) + } } catch { throw Error.gettingAccessToken(error) }