arjuna.tpi.httpauto.oauth module

class arjuna.tpi.httpauto.oauth.OAuthClientGrantSession(*, url=None, client_id=None, client_secret=None, token_url=None)

Bases: arjuna.tpi.httpauto.oauth.OAuthSession

Creates token using OAuth’s Resource Owner Client Credentials Grant Type. Uses BackendApplicationClient from requests_oauthlib.

Keyword Arguments
  • url – Base URL for this HTTP session. If relative path is used as a route in sender methods like .get, then this URL is prefixed to their provided routes.

  • client_id – Client ID

  • client_secret – Client Secret

  • token_url – Token URL

class arjuna.tpi.httpauto.oauth.OAuthImplicitGrantSession(*, url=None, client_id=None, scope=None, redirect_uri=None, auth_url=None, auth_handler=None, **auth_args)

Bases: arjuna.tpi.httpauto.oauth.OAuthSession

Creates token using OAuth’s Implicit Code Grant Type. Uses MobileApplicationClient from requests_oauthlib.

Keyword Arguments
  • url – Base URL for this HTTP session. If relative path is used as a route in sender methods like .get, then this URL is prefixed to their provided routes.

  • client_id – Client ID

  • scope – Scope

  • redirect_uri – Redirect URI

  • auth_url – Authorization URL

  • auth_handler – A callback function to handle custom authroization logic. It will be called by providing session object, authorization URL and auth_args.

  • **auth_args – Arbitray key-value pairs to be passed as arguments to the auth_handler callback.

Note

Some sample auth_handler signatures:

auth_handler_1(oauth_session, auth_url, **kwargs)
auth_handler_2(oauth_session, auth_url, some_arg=None, another_arg="some_def_value")
class arjuna.tpi.httpauto.oauth.OAuthSession(*, session=None, url=None)

Bases: arjuna.tpi.httpauto.session.HttpSession

Base Class for all types of OAuth Http Sessions.

Parameters
  • sessionrequests_oauthlib session object

  • url – Base URL for this HTTP session. If relative path is used as a route in sender methods like .get, then this URL is prefixed to their provided routes.

create_new_session(url, *, request_content_handler=None, headers=None, max_redirects=None, auth=None, proxy=None)

Create a new HttpSession object. OAuth token of this session is attached to the new session.

Parameters

url – Base URL for the new HTTP session.

Keyword Arguments
  • request_content_handler – Default content type handler for requests sent in this session. Overridable in individual sender methods. Default is Http.content.urlencoded.

  • headers – HTTP headers to be added to request headers made by this session.

  • max_redirects – Maximum number of redirects allowed for a request. Default is 30.

  • auth – HTTP Authentication object: Basic/Digest.

  • proxy – Proxies dict to be associated with this session.

property token

OAuth Token created by this session.