OAuthClient

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

Pysnow Client with extras for oauth session and token handling.

Parameters:
  • client_id – client_id from ServiceNow
  • client_secret – client_secret from ServiceNow
  • token_updater – function called when a token has been refreshed
  • kwargs – kwargs passed along to pysnow.Client
set_token(token)[source]

Validate and set token

Parameters:token – the token (dict) to set
resource(api_path=None, base_path='/api/now', chunk_size=None)[source]

Overrides resource() provided by pysnow.Client with extras for OAuth

Parameters:
  • api_path – Path to the API to operate on
  • base_path – (optional) Base path override
  • chunk_size – Response stream parser chunk size (in bytes)
Returns:

  • Resource object

Raises:
  • InvalidUsage: If a path fails validation
generate_token(user, password)[source]

Takes user and password credentials and generates a new token

Parameters:
  • user – user
  • password – password
Returns:

  • dictionary containing token data

Raises:
  • TokenCreateError: If there was an error generating the new token