ClientSession#

class fourinsight.api.ClientSession(client_id, client_secret)[source]#

Authorized session where credentials are given as client_id and client_secret. When valid credentials are presented, the session is authenticated and persisted.

Extends BaseAuthSession.

Parameters:
  • client_id (str) – Unique identifier for the client (i.e. app/service etc.).

  • client_secret (str) – Secret/password for the client.

fetch_token()[source]#

Fetch new access and refresh token.

get(*args, **kwargs)[source]#

Extend the requests_oauthlib.OAuth2Session.get method to ensure that internal API are not accessed.

get_pages(url, **kwargs)[source]#

Sends GET requests, and returns a generator that lets the user iterate over paginated responses. Note that the endpoint must support OData; the json response should include the a parameter @odata.nextLink’, providing the URL for the next page.

Parameters:
  • url (str) – API endpoint. To return pages, the endpoint must support OData and contain the parameter @odata.nextLink’.

  • **kwargs – Optional keyword arguments. Will be passed on to the get method.

Yields:

response (obj) – The response as a Response object.

refresh_token(*args, **kwargs)[source]#

Refresh (expired) access token

request(*args, **kwargs)[source]#

Extend the requests_oauthlib.OAuth2Session.request method to supply default arguments.