Skip to content

Commit

Permalink
Retry auth finalization if it fails the first time
Browse files Browse the repository at this point in the history
There's some known issue in the auth flow where trying to auth twice in the same app session seems to fail the second time, particularly if there's a short turnaround between the end of the last session and the beginning of the new auth.

It seems to be related to trying to re-use a network connection that is now closed.

I'm not sure what the correct fix is, but this workaround addresses it by doing a single-shot retry:

More info here:

https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Re-linking-using-Obj-C-SDK-fails-with-network-error/td-p/593634
  • Loading branch information
syrupticious committed Mar 30, 2023
1 parent 222fe67 commit d36413c
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,15 @@ - (void)db_handleCodeFlowUrl:(NSURL *)url
authCode = parametersMap[kDBOauthSecretKey];
}
if (authCode) {
[self finishPkceOAuthWithAuthCode:authCode codeVerifier:authSession.pkceData.codeVerifier completion:completion];
[self finishPkceOAuthWithAuthCode:authCode codeVerifier:authSession.pkceData.codeVerifier completion:^(DBOAuthResult * _Nullable result) {
if (result.isError) {
// Single-shot retry to attempt to workaround a known issue that seems to be caused by trying to re-use a dead connection.
// https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Re-linking-using-Obj-C-SDK-fails-with-network-error/td-p/593634
[self finishPkceOAuthWithAuthCode:authCode codeVerifier:authSession.pkceData.codeVerifier completion:completion];
} else {
completion(result);
}
}];
} else {
completion([DBOAuthResult unknownErrorWithErrorDescription:@"Unable to verify link request."]);
}
Expand Down

0 comments on commit d36413c

Please sign in to comment.