For those still struggling with this like I was, chances are you are working off of localhost.
If you’re using usePopup: true as an option, the URL in which the script is initialized NEEDS to match redirectURI at the top level. Since Apple won’t let you use localhost as a valid redirectURI, you’ll need to add an entry to /etc/hosts such as:
0.0.1			mywebsite-dev.com
Then you can use mywebsite-dev.com in your redirectURI as long as you added in your certificate.
Hope this helps.