Github Oauth Cross-Origin Issues

Hello!

I have a site that when the user signs in; it opens a new window to github login to use it’s oauth flow. The user signs in, grants access, and is redirect back to the site. https://www.site.com?code=“code”. My site then attempts to parse the code out of window.location.search. However, when this occurs I am getting the following error:

DOMException: Permission denied to get property “href” on cross-origin object.

I am not sure what to do in this case? Any thoughts would be appreciated.