arjuna.tpi.httpauto.oauth module

class arjuna.tpi.httpauto.oauth.OAuthClientGrantService(*, name='anon', url, client_id, client_secret, token_url)

Bases: arjuna.tpi.httpauto.oauth.OAuthService

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

Keyword Arguments
  • name – Name of service. Should have a corresponding named directory in Project root/httpauto/service directory. If not provided then the name is set to anon and root directory is set to Project root/httpauto.

  • 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.OAuthImplicitGrantService(*, name='anon', url, client_id, scope, redirect_uri=None, auth_url, auth_handler=None, **auth_args)

Bases: arjuna.tpi.httpauto.oauth.OAuthService

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

Keyword Arguments
  • name – Name of service. Should have a corresponding named directory in Project root/httpauto/service directory. If not provided then the name is set to anon and root directory is set to Project root/httpauto.

  • url – Base URL for this HTTP service. 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_service, auth_url, **kwargs)
auth_handler_2(oauth_service, auth_url, some_arg=None, another_arg="some_def_value")
class arjuna.tpi.httpauto.oauth.OAuthService(*, session, name, url)

Bases: arjuna.tpi.httpauto.service.HttpService

Base Class for all types of OAuth Http Sessions.

Parameters
  • sessionrequests_oauthlib session object

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

create_new_service(url, *, name='anon', request_content_handler=None, headers=None, max_redirects=None, auth=None, proxy=None)

Create a new HttpService object. OAuth token of this service is attached to the new service.

Parameters

url – Base URL for the new HTTP session.

Keyword Arguments
  • request_content_handler – Default content type handler for requests sent in the new service. 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 the new service.

property token

OAuth Token created by this session.