RPA.MSGraph

Exchanges the OAuth authorization URL obtained from Generate OAuth Authorization URL for an access token. This library maintains the user access token for current requests and returns the refresh token to be stored in a secure location (e.g., the Robocorp Control Room Vault).

Arguments

ArgumentTypeDefault value
authorization_urlstrnull
param authorization_url:The full URL retrieved by the user after completing authorization to Microsoft.
return:A refresh token which should be stored securely for future sessions.

Configures the MS Graph client. If a refresh token is known, it can be provided to obtain a current user token to authenticate with. A new refresh token is returned if one is provided.

Arguments

ArgumentTypeDefault value
client_idstrnull
client_secretstrnull
refresh_tokenstr, NoneNone
redirect_uristr, NoneNone
param client_id:Application client ID.
param client_secret:Application client secret.
param refresh_token:Authorization refresh token obtained from prior OAuth flows.
param redirect_uri:Must be provided with client ID and client secret if not using the default.
return:A new refresh token if one was provided, or None.

Creates a sharepoint list and returns the instance.

Arguments

ArgumentTypeDefault value
list_datadictnull
siteSitenull
param list_data:Dictionary with the data for the new list.
param site:Site instance obtained from Get Sharepoint Site.
return:SharePoint List that was created.

SharepointList objects have additional properties that can be accessed with dot-notation, see examples below.

Downloads a file from Onedrive.

Arguments

ArgumentTypeDefault value
target_fileFile, strnull
to_pathstr, Path, NoneNone
namestr, NoneNone
resourcestr, NoneNone
driveDrive, str, NoneNone

The downloaded file will be saved to a local path.

param target_file:DriveItem or file path of the desired file.
param to_path:Destination folder of the downloaded file, defaults to the current directory.
param name:New name for the downloaded file, with or without extension.
param resource:Name of the resource if not using default.
param drive:A Drive object or Drive ID as a string. If not provided, will use the default drive.
return:Path to the downloaded file.

Downloads file from SharePoint.

Arguments

ArgumentTypeDefault value
target_fileFile, strnull
siteSitenull
to_pathstr, Path, NoneNone
namestr, NoneNone
driveDrive, str, NoneNone

The downloaded file will be saved to a local folder.

param target_file:DriveItem or file path of the desired file.
param site:Site instance obtained from Get Sharepoint Site.
param to_path:Destination folder of the downloaded file, defaults to the current directory.
param name:New name for the downloaded file, with or without extension.
param drive:A Drive object or a Drive ID as a string.
return:Path to the downloaded file.

Downloads a folder from OneDrive with all of its contents, including subfolders.

Arguments

ArgumentTypeDefault value
target_folderFolder, strnull
to_pathstr, Path, NoneNone
resourcestr, NoneNone
driveDrive, str, NoneNone

Caution when downloading big folder structures. The downloaded folder will be saved to a local path.

param target_folder:DriveItem or path of the desired folder.
param to_path:Destination folder where the download will be saved to, defaults to the current directory.
param resource:Name of the resource if not using default.
param drive:A Drive object or Drive ID as a string. If not provided, will use the default drive.
return:Path to the downloaded folder.

Returns a list of files found in OneDrive based on the search string. If a folder is not specified, the search is done in the entire drive and may include items that were shared with the user. It is possible to pass root as the target folder in order to avoid this behavior.

Arguments

ArgumentTypeDefault value
search_stringstrnull
target_folderFolder, str, NoneNone
include_foldersbool, NoneFalse
resourcestr, NoneNone
driveDrive, str, NoneNone

The files returned are DriveItem objects and they have additional properties that can be accessed with dot-notation, see List Files In Onedrive Folder for details.

param search_string:String used to search for file in Onedrive. Values may be matched across several fields including filename, metadata, and file content.
param target_folder:Folder where to search for files.
param include_folders:Boolean indicating if should return folders as well.
param resource:Name of the resource if not using default.
param drive:A Drive object or Drive ID as a string. If not provided, will use the default drive.
return:List of DriveItems found based on the search string.

Generates an authorization URL which must be opened by the user to complete the OAuth flow. If no scopes are provided, the default scope is used which is all scopes defined in the Get Scopes keyword.

Arguments

ArgumentTypeDefault value
client_idstr, NoneNone
client_secretstr, NoneNone
redirect_uristr, NoneNone
scopeslist, NoneNone
param client_id:Application client ID.
param client_secret:Application client secret.
param redirect_uri:Can be provided with client ID and client secret if not using the default.
param scopes:A list of scopes in the form required by the API. Use the helper function Get scopes.
return:The URL the user must follow to complete their portion of the OAuth flow.

Returns the specified drive from the specified resource. If either is not provided, defaults are returned.

Arguments

ArgumentTypeDefault value
resourcestr, NoneNone
drive_idstr, NoneNone
param resource:Name of the resource if not using default.
param drive_id:The Drive ID as a string.
return:The requested Drive object.

Returns a File object from the provided drive. If a File object is provided, it is reobtained from the API.

Arguments

ArgumentTypeDefault value
driveDrive, strnull
fileFile, strnull
param drive:A Drive object or Drive ID as a string. If not provided, will use the default drive.
param file_path:A File object or path as a string.

Returns a folder object from the provided drive. If a folder object is provided, it is reobtained from the API.

Arguments

ArgumentTypeDefault value
driveDrive, str, NoneNone
folderFolder, str, NoneNone
param drive:A Drive object or Drive ID as a string. If not provided, will use the default drive.
param folder:A Folder object or folder path as a string.

Returns the items on a SharePoint list as a table. The list is found by it's display name.

Arguments

ArgumentTypeDefault value
list_namestrnull
siteSitenull
param list_name:Display name of the SharePoint list.
param site:Site instance obtained from Get Sharepoint Site.
return:Table or list of dicts of the items.

Returns the MS Graph object representing the currently logged in user. A User object is returned. Properties of the user can be accessed like so:

Returns the proper scope definitions based on the provided "scope helpers", which are enumerated below. You can pass none to get all scopes. Basic is included in all other scopes. The provided object can be passed to the scopes parameter when calling Generate OAuth Authorization URL.

Arguments

ArgumentTypeDefault value
scopesstrnull
  • basic
  • mailbox
  • mailbox_shared
  • message_send
  • message_send_shared
  • message_all
  • message_all_shared
  • address_book
  • address_book_shared
  • address_book_all
  • address_book_all_shared
  • calendar
  • calendar_shared
  • calendar_all
  • calendar_shared_all
  • users
  • onedrive
  • onedrive_all
  • sharepoint
  • sharepoint_dl
  • settings_all
  • tasks
  • tasks_all
  • presence
param scopes:Scopes requested. If left empty, all scopes will be returned.
return:A list of Scopes which can be passed to authorization keywords.

Returns a SharePoint site.

Arguments

ArgumentTypeDefault value
argsstrnull
resourcestr, None
param args:The SharePoint site to retrieve, see documentation for different methods of defining the site.
param resource:Name of the resource if not using default.
return:SharePoint Site instance.

There are multiple ways of retrieving a SharePoint site:

The return is of type Site and it has additional properties that can be accessed with dot-notation. See examples below.

Returns a list of files from the specified OneDrive folder.

Arguments

ArgumentTypeDefault value
target_folderFolder, str, NoneNone
include_foldersbool, NoneFalse
resourcestr, NoneNone
driveDrive, str, NoneNone

The files returned are DriveItem objects and they have additional properties that can be accessed with dot-notation.

param target_folder:Path of the folder in Onedrive. If none is provided, will return files from the root of Onedrive.
param include_folders:Boolean indicating if should return folders as well.
param resource:Name of the resource if not using default.
param drive:A Drive object or Drive ID as a string. If not provided, will use the default drive.
return:List of DriveItems in the folder.

List files in the SharePoint Site drive.

Arguments

ArgumentTypeDefault value
siteSitenull
include_foldersbool, NoneFalse
driveDrive, str, NoneNone
target_folderFolder, str, NoneNone

If the drive is not set, the default Document Library will be used. The drive can be obtained from the keyword List Sharepoint Site Drives.

The files returned are DriveItem objects and they have additional properties that can be accessed with dot-notation, see List Files In Onedrive Folder for details.

param site:Site instance obtained from Get Sharepoint Site.
param include_folders:Boolean indicating if should return folders as well.
param drive:A Drive object or Drive ID as a string. If not provided, will use the default drive.
param target_folder:Path of the folder in the Sharepoint drive. If none is provided, will return files from the root of the drive.
return:List of DriveItems present in the Site drive.

Get a list of Drives available in the SharePoint Site.

Arguments

ArgumentTypeDefault value
siteSitenull
param site:Site instance obtained from Get Sharepoint Site.
return:List of Drives present in the SharePoint Site.

Refreshes the user token using the provided refresh_token. The user token is retained in the library and a new refresh token is returned. If no token is provided, this keyword assumes the Robocorp Vault is being used as a backend and attempts to refresh it based on that backend.

Arguments

ArgumentTypeDefault value
refresh_tokenstr, NoneNone
param refresh_token:The refresh token to use to refresh the session.
return:A refresh token which should be stored securely for future sessions.

Returns a list of User objects from the Active Directory based on the provided search string.

Arguments

ArgumentTypeDefault value
search_stringstrnull
search_fieldstrdisplayName
resourcestrusers

User objects have additional properties that can be accessed with dot-notation, see Get Me for additional details.

param search_string:Text to search for.
param search_field:Where to search. Defaults to display name.
param resource:Name of the resource if not using default.

Uploads a file to the specified OneDrive folder.

Arguments

ArgumentTypeDefault value
file_pathstrnull
target_folderFolder, str, NoneNone
resourcestr, NoneNone
driveDrive, str, NoneNone

The uploaded file is returned as a DriveItem object and it has additional properties that can be accessed with dot-notation, see List Files In Onedrive Folder for details.

param file_path:Path of the local file being uploaded.
param target_folder:Path of the folder in Onedrive.
param resource:Name of the resource if not using default.
param drive:A Drive object or Drive ID as a string. If not provided, will use the default drive.
return:The newly created DriveItem.