Niklas Klein
1 min readJun 21, 2023

--

That's an interesting pattern, and please correct me if I'm wrong, but I don't think it would solve the problem I described in the article:

> In my case, I was integrating Single sign-on (SSO) from Twitter into a website. When a user accepts my app permissions on Twitter, they are redirected back to my website with some special tokens in the query parameters (e.g. /sso/twitter?oauth_token=xxx). When this page loads, all I have to do is send the token to my backend and wait for it to return a user session. Afterwards I simply redirect into the user dashboard. But guess what happens if the backend request is triggered twice? Well, both requests will fail with a 500 error as Twitter rejects my attempt to obtain two OAuth access tokens for the same user simultaneously.

Aborting an HTTP request after an undetermined amount of time (the time it takes for react to mount and unmount initially for debug purposes) is not something I can perform deterministically. Even if it works out most of the times, the first request might still make it through occasionally.

--

--

Responses (1)