cloudsync.oauth

class cloudsync.oauth.OAuthConfig(*, app_id: str, app_secret: str, manual_mode: bool = False, redirect_server: Optional[cloudsync.oauth.redir_server.OAuthRedirServer] = None, port_range: Tuple[int, int] = None, host_name: str = None)

Required argument for providers that return True to uses_oauth.

Args:

app_id: also known as “client id”, provided for your application by the cloud provider app_secret: also known as “client secret”, provided for your application by the cloud provider manual_mode: set to True, if you don’t intend to use the redirect server redirect_server: a server that, at a minimum, supports the uri() command, probably should just change this to uri() port_range: the range of valid ports for your registered app (some providers burden you with this) host_name: defaults to 127.0.0.1

creds_changed(creds: Any)

Override this to save creds on refresh

property failure_info
static failure_message(error_str: str) → str
property redirect_uri

Get the redirect server’s uri

refresh(refresh_url, token=None, scope=None, **extra)

Given a refresh url (often the same as token_url), will refresh the token Call this when your provider raises an exception implying your token has expired Or, you could just call it before the expiration

server_close()

Close the redirect server and join all threads

shutdown()

Stop the redirect server, and interrupt/fail any ongoing oauth

start_auth(auth_url, scope=None, **kwargs)

Call this if you want oauth to be handled for you This starts a server, pops a browser. Do some stuff, then follow with wait_auth() to wait

start_server(*, on_success=None, on_failure=None)

Start the redirect server in a thread

property success_code
static success_message() → str
wait_auth(token_url, timeout=None, **kwargs)

Returns an OAuthToken object, or raises a OAuthError

wait_success(timeout=None)

Wait for the redirect server, return true if it succeeded Shut down the server

class cloudsync.oauth.OAuthProviderInfo

Providers can set their ._oauth_info protected member to one of these.

property auth_url

Alias for field number 0

property scopes

Alias for field number 2

property token_url

Alias for field number 1