Workaround for issues signing in to m.s

This commit is contained in:
Shadowfacts 2023-01-24 20:43:56 -05:00
parent 125f91257a
commit 8b546daeaa
1 changed files with 11 additions and 0 deletions

View File

@ -51,14 +51,25 @@ class OnboardingViewController: UINavigationController {
do { do {
(clientID, clientSecret) = try await mastodonController.registerApp() (clientID, clientSecret) = try await mastodonController.registerApp()
self.clientInfo = (instanceURL, clientID, clientSecret) 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 { } catch {
throw Error.registeringApp(error) throw Error.registeringApp(error)
} }
} }
let authCode = try await getAuthorizationCode(instanceURL: instanceURL, clientID: clientID) 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 let accessToken: String
do { do {
accessToken = try await mastodonController.authorize(authorizationCode: authCode) accessToken = try await mastodonController.authorize(authorizationCode: authCode)
if instanceURL.host == "mastodon.social" {
try await Task.sleep(nanoseconds: 2 * NSEC_PER_SEC)
}
} catch { } catch {
throw Error.gettingAccessToken(error) throw Error.gettingAccessToken(error)
} }