DOI-BLM / requests-arcgis-auth

Authentication handler for using Esri ArcGIS for Server and Portal (ArcGIS Online) Token Authentication with Python Requests
22 stars 1 forks source link

update wiki to reflect 'Verify' parameter #17

Open pfoppe opened 7 years ago

pfoppe commented 7 years ago

Worked out a way to read the windows CA certs and make those trusted... This would be the preferred solution so that the certificates are still verified.

Need to fully test solution first...

Kudos to @AltitudeGIS encouraging identifying a solution to this...


# Get certs and store them!

ca_cert_file = r'C:\tmp\cacerts.pem'
f = open (ca_cert_file,'wb')
import wincertstore
for storename in ("CA", "ROOT"):
    with wincertstore.CertSystemStore(storename) as store:
        for cert in store.itercerts(usage=wincertstore.SERVER_AUTH):
            print(cert.get_pem().decode("ascii"))
            print(cert.get_name())
            print(cert.enhanced_keyusage_names())
            f.write(cert.get_pem().decode("ascii"))
f.close()

import requests
from requests_arcgis_auth import ArcGISPortalSAMLAuth
s = requests.session()
s.auth = ArcGISPortalSAMLAuth('CLIENT_ID',verify = ca_cert_file)
r = s.get(r'https://ORG.maps.arcgis.com/sharing/rest/portals/self?f=json',verify = ca_cert_file)
print r.json().get('user')`