onedrive.auth module

Authenticate with OneDrive’s API and make authenticated HTTP requests.

class onedrive.auth.OneDriveOAuthClient(authorize=False)[source]

Bases: builtins.object

Interface for dancing with OneDrive’s OAuth.

Parameters:

authorize : bool, optional

If authorize is True, authorize the client and generate a new refresh token (requires tty interaction); otherwise, assume the refresh token is already present in the config file, and raise if it is not available.

Returns:

OSError

If the config file or any necessary config section/parameter is missing.

API_ENDPOINT = 'https://api.onedrive.com/v1.0/'
authorize_client()[source]

Authorize the client using the code flow.

delete(url, **kwargs)[source]

HTTP DELETE with OAuth.

get(url, params=None, **kwargs)[source]

HTTP GET with OAuth.

head(url, **kwargs)[source]

HTTP HEAD with OAuth.

options(url, **kwargs)[source]

HTTP OPTIONS with OAuth.

patch(url, data=None, **kwargs)[source]

HTTP PATCH with OAuth.

post(url, data=None, json=None, **kwargs)[source]

HTTP POST with OAuth.

put(url, data=None, **kwargs)[source]

HTTP PUT with OAuth.

refresh_access_token()[source]

Get new access token with refresh token.

request(method, url, **kwargs)[source]

HTTP request with OAuth and safeguards.

The noretry keyword argument is used internally to determine if another attempt should be made on a timeout, or HTTP 429 (Too Many Requests), 500 (Internal Server Error), or 503 (Service Unavailable). The default value is True.

onedrive.auth.main()[source]

Authorization CLI.

Previous topic

onedrive.api module

Next topic

onedrive.cli module

This Page