pysnow.OAuthClient — Creates a new client with OAuth extras

class pysnow.OAuthClient(client_id=None, client_secret=None, token_updater=None, *args, **kwargs)[source]

Pysnow Client with extras for oauth session and token handling.

This API exposes two extra public methods:

  • generate_token(user, pass)
    • This method takes user and password credentials to generate a new OAuth token that can be stored outside the context of pysnow, e.g. in a session or database.
  • set_token(token)
    • Takes an OAuth token (dict) and internally creates a new pysnow-compatible session, enabling pysnow.OAuthClient to create requests.
  • client_id – client_id from ServiceNow
  • client_secret – client_secret from ServiceNow
  • token_updater – callback function called when a token has been refreshed
  • instance – instance name, used to construct host
  • host – host can be passed as an alternative to instance
  • raise_on_empty – whether or not to raise an exception on 404 (no matching records)
  • request_params – request params to send with requests
  • use_ssl – Enable or disable SSL

Validates token and creates a pysnow compatible session

Parameters:token – dict containing the information required to create an OAuth2Session
generate_token(user, password)[source]

Takes user and password credentials and generates a new token

  • user – user
  • password – password

dictionary containing token data