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.3.0', max_retries=2, pool_connections=20, pool_maxsize=50, **kwargs)¶ Bases:
requests_oauthlib.oauth2_session.OAuth2Session
Main class in Isogeo API Python wrapper. Manage authentication and requests to the REST API. Inherits from
requests_oauthlib.OAuth2Session
.Inherited:
Parameters: - client_id (str) – Client id obtained during registration
- redirect_uri (str) – Redirect URI you registered as callback
- auto_refresh_url (list) – Refresh token endpoint URL, must be HTTPS. Supply this if you wish the client to automatically refresh your access tokens.
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
Returns: authenticated requests Session you can use to send requests to the API.
Return type: requests_oauthlib.OAuth2Session
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'>}}¶
-
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
Parameters: - username (str) – user login (email). Not required for group apps (Client Credentials).
- password (str) – user password. Not required for group apps (Client Credentials).
-
classmethod
guess_auth_mode
()¶
-
header
¶ Return type: dict