Problem

jwt.exceptions.PyJWKClientConnectionError: Fail to fetch data from the url, err: "<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:992)>"

Solution

Python does not rely on MacOS' openSSL anymore. It comes with its own openSSL bundled and doesn't have access on MacOS' root certificates.

Run an install command shipped with Python
  1. Execute the command 
    1. /Applications/Python\ 3.11/./Install\ Certificates.command

      You may need to give write access to the folders

      • /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/certifi/
      • /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/certifi-2023.5.7.dist-info

      Or the version in your current sistem