title: Salesforce OAuth 2.0 implementation CRA
body: <p>I am attempting to grab the authorization code appended to the redirect uri using the OAuth2.0 Web Server Flow for Web App Integration seen here: <a href="https://help.salesforce.com/s/articleView?id=sf.remoteaccess_oauth_web_server_flow.htm&amp;type=5" rel="nofollow noreferrer">https://help.salesforce.com/s/articleView?id=sf.remoteaccess_oauth_web_server_flow.htm&amp;type=5</a></p>
  <p>When a user hits a button, I am opening a child window where the user authorizes via OAuth and is then redirected to the callback uri upon successful verification, etc.  Is there a way to access the url of the child window and grab the authorization code as well as close the child window upon successful verification.  My code is as follows:</p>
  <pre><code>const Dashboard = () =&gt; {
    const openWindow = () =&gt; {
      const newWindow = window.open(
        `${salesforceAppUrl}/services/oauth2/authorize?&amp;response_type=code&amp;client_id=${clientId}&amp;redirect_uri=https://login.salesforce.com/services/oauth2/success`,
        '',
        'width=850,toolbar=1,resizable=1,scrollbars=yes,height=700,top=100,left=100'
      )
      console.log(newWindow)
    }
  
    return &lt;button onClick={openWindow}&gt;test&lt;/button&gt;
  }
  
  export default Dashboard
  </code></pre>
  <p>I am wondering if I am going about this correct way/looking for guidance on the proper way to go about grabbing the authorization code from the redirect uri when a successfully auths.  Any and all suggestions would be greatly appreciated.</p>