route1io_connectors.onedrive module

OneDrive

The purpose of this module is for uploading/downloading files to/from OneDrive and SharePoint via the Microsoft Graph API

permissions_prompt(tenant_id: str, client_id: str, scope: List[str]) None

Convenience function for opening web browser to permissions prompt

refresh_access_token(client_id: str, client_secret: str, refresh_token: str, scope: List[str], tenant_id: str) Dict[str, str]

Return dictionary of refreshed access token information

request_access_token(code: str, tenant_id: str, client_id: str, scope: List[str], redirect_uri: str, client_secret: str) Dict[str, str]

Return a dict of authentication information using the code provided from redirect URI

Parameters
  • code (str) – Code acquired after accepting app permissions request and redirecting to redirect URI

  • tenant_id (str) – User tenant ID

  • client_id (str) – Client ID acquired after registering an app with Azure Active Directory

  • scope (str) – List of scopes to acquire access token for

  • redirect_uri (str) – Redirect URI

  • client_secret (str) – Client secret for signing request

Returns

Dictionary containing access credentials that were just requested

Return type

Dict[str, str]

search_sharepoint_site(access_token: str, search: str) Dict[str, str]

Return results of find SharePoint site(s) by keyword search

Parameters
  • access_token (str) – Valid access token for accessing SharePoint

  • search (str) – Search term for finding site

Returns

Returns response JSON

Return type

Dict[str, str]

upload_file(access_token: str, url: str, fpath: str) Dict[str, str]

Upload file locally to OneDrive at specified URL. Note: URL must be suffixed with /content to work

Parameters
  • access_token (str) – Valid access token

  • url (str) – Valid Microsoft Graph API URL of the file we are going to update and/or create

  • fpath (str) – Local fpath of the file we will upload to OneDrive location specified at url

Returns

resp – Dictionary of information pertaining to recently uploaded file

Return type

Dict[str, str]