Account

class O365.account.Account(credentials, *, protocol=None, main_resource=None, **kwargs)[source]

Bases: object

__init__(credentials, *, protocol=None, main_resource=None, **kwargs)[source]

Creates an object which is used to access resources related to the specified credentials

Parameters
  • credentials (tuple) – a tuple containing the client_id and client_secret

  • protocol (Protocol) – the protocol to be used in this account

  • main_resource (str) – the resource to be used by this account (‘me’ or ‘users’, etc.)

  • kwargs – any extra args to be passed to the Connection instance

Raises

ValueError – if an invalid protocol is passed

address_book(*, resource=None, address_book='personal')[source]

Get an instance to the specified address book for the specified account resource

Parameters
  • resource (str) – Custom resource to be used in this address book (Defaults to parent main_resource)

  • address_book (str) – Choose from ‘Personal’ or ‘Directory’

Returns

a representation of the specified address book

Return type

AddressBook or GlobalAddressList

Raises

RuntimeError – if invalid address_book is specified

authenticate(*, scopes=None, **kwargs)[source]

Performs the oauth authentication flow using the console resulting in a stored token. It uses the credentials passed on instantiation

Parameters
  • or None scopes (list[str]) – list of protocol user scopes to be converted by the protocol or scope helpers

  • kwargs – other configurations to be passed to the Connection.get_authorization_url and Connection.request_token methods

Returns

Success / Failure

Return type

bool

property connection

Alias for self.con

Return type

type(self.connection_constructor)

connection_constructor

alias of O365.connection.Connection

directory(resource=None)[source]

Returns the active directory instance

get_current_user()[source]

Returns the current user

property is_authenticated

Checks whether the library has the authentication and that is not expired :return: True if authenticated, False otherwise

mailbox(resource=None)[source]

Get an instance to the mailbox for the specified account resource

Parameters

resource (str) – Custom resource to be used in this mailbox (Defaults to parent main_resource)

Returns

a representation of account mailbox

Return type

O365.mailbox.MailBox

new_message(resource=None)[source]

Creates a new message to be sent or stored

Parameters

resource (str) – Custom resource to be used in this message (Defaults to parent main_resource)

Returns

New empty message

Return type

Message

outlook_categories(*, resource='')[source]

Returns a Categories object to handle the available Outlook Categories

planner(*, resource='')[source]

Get an instance to read information from Microsoft planner

schedule(*, resource=None)[source]

Get an instance to work with calendar events for the specified account resource

Parameters

resource (str) – Custom resource to be used in this schedule object (Defaults to parent main_resource)

Returns

a representation of calendar events

Return type

Schedule

sharepoint(*, resource='')[source]

Get an instance to read information from Sharepoint sites for the specified account resource

Parameters

resource (str) – Custom resource to be used in this sharepoint object (Defaults to parent main_resource)

Returns

a representation of Sharepoint Sites

Return type

Sharepoint

Raises

RuntimeError – if protocol doesn’t support the feature

storage(*, resource=None)[source]

Get an instance to handle file storage (OneDrive / Sharepoint) for the specified account resource

Parameters

resource (str) – Custom resource to be used in this drive object (Defaults to parent main_resource)

Returns

a representation of OneDrive File Storage

Return type

Storage

Raises

RuntimeError – if protocol doesn’t support the feature

teams(*, resource='')[source]

Get an instance to read information from Microsoft Teams