isogeo_pysdk.isogeo module
Python SDK wrapping the Isogeo API.
Author: Julien Moura (@geojulien) for @Isogeo
- class isogeo_pysdk.isogeo.Isogeo(auth_mode='group', client_secret=None, platform='qa', proxy=None, timeout=(15, 45), lang='fr', app_name='isogeo-pysdk/3.8.0', max_retries=2, pool_connections=20, pool_maxsize=50, isogeo_urls={}, **kwargs)
Bases:
OAuth2Session
Main class in Isogeo API Python wrapper. Manage authentication and requests to the REST API. Inherits from
requests_oauthlib.OAuth2Session
.Inherited:
- Parameters
Package specific:
- Parameters
client_secret (str) – application oAuth2 secret
auth_mode (str) – oAuth2 authentication flow to use. Must be one of ‘AUTH_MODES’
platform (str) – to request production or quality assurance
proxy (dict) – dictionary of proxy settings as described in Requests
lang (str) – API localization (“en” or “fr”). Defaults to ‘fr’.
app_name (str) – to custom the application name and user-agent
max_retries (int) –
custom the maximum number of retries each connection should attempt. See: Requests
pool_connections (int) –
custom the number of urllib3 connection pools to cache. See: Requests
pool_maxsize (int) –
custom the maximum number of connections to save in the pool. See: Requests
isogeo_urls (dict) – Only needed when platform is “custom”, a dictionnary of specific Isogeo URLs.
- Returns
authenticated requests Session you can use to send requests to the API.
- Return type
- Example
# using oAuth2 Password Credentials Grant (Legacy Application) # (for scripts executed on the server-side with user credentials # but without requiring user action) isogeo = Isogeo( client_id=environ.get("ISOGEO_API_USER_LEGACY_CLIENT_ID"), client_secret=environ.get("ISOGEO_API_USER_LEGACY_CLIENT_SECRET"), auth_mode="user_legacy", auto_refresh_url="{}/oauth/token".format(environ.get("ISOGEO_ID_URL")), platform=environ.get("ISOGEO_PLATFORM", "qa"), ) # getting a token isogeo.connect( username=environ.get("ISOGEO_USER_NAME"), password=environ.get("ISOGEO_USER_PASSWORD"), ) # using oAuth2 Client Credentials Grant (Backend Application) # (for scripts executed on the server-side with only application credentials # but limited to read-only in Isogeo API) isogeo = Isogeo( client_id=environ.get("ISOGEO_API_DEV_ID"), client_secret=environ.get("ISOGEO_API_DEV_SECRET"), auth_mode="group", auto_refresh_url="{}/oauth/token".format(environ.get("ISOGEO_ID_URL")), platform=environ.get("ISOGEO_PLATFORM", "qa"), ) # getting a token isogeo.connect()
- AUTH_MODES = {'group': {'client_id': <class 'str'>, 'client_secret': <class 'str'>}, 'guess': {}, 'user_legacy': {'auto_refresh_url': <class 'str'>, 'client_id': <class 'str'>, 'client_secret': <class 'str'>}, 'user_private': {'auto_refresh_url': <class 'str'>, 'client_id': <class 'str'>, 'client_secret': <class 'str'>, 'redirect_uris': <class 'list'>}, 'user_public': {'auto_refresh_url': <class 'str'>, 'client_id': <class 'str'>, 'client_secret': <class 'str'>, 'redirect_uris': <class 'list'>}}
- PLATFORM_VALUES = ['qa', 'prod', 'custom']
- connect(username=None, password=None)
Custom the HTTP client and authenticate application with user credentials and fetch token.
Isogeo API uses oAuth 2.0 protocol (https://tools.ietf.org/html/rfc6749) see: http://help.isogeo.com/api/fr/authentication/concepts.html
- classmethod guess_auth_mode()