React: Implement OAuth2 with hooks Step 1: Prepare the hook. The props that our hook will need are: Step 2: Generate state. Before constructing the authorization URL, we need to generate a state parameter. ... Step 3: Open the Popup. ... Step 4: Listen to Popup messages. ... Step 5: Exchange code with an access token. Apr 18, 2022