Microsoft Graph和Office 365 API简化了
O365的Python项目详细描述
O365-Microsoft Graph和Office 365 API简化了
< Buff行情>详细的使用说明文档仍在进行中
这个项目的目标是使与微软图形和Office 365的交互变得简单易如反掌。 对电子邮件、日历、联系人、OneDrive等的访问很容易做到,对初学者来说很容易做到,对经验丰富的Python程序员来说也很容易做到。
该项目目前由Toben Archer、Royce Melborn和Janscas开发和维护,但我们始终欢迎新的拉取请求。
例如,这是您发送消息的方式:
fromO365importAccountcredentials=('client_id','client_secret')account=Account(credentials)m=account.new_message()m.to.add('to_example@example.com')m.subject='Testing!'m.body="George Best quote: I've stopped drinking, but only while I'm asleep."m.send()
为什么选择O365?
- 几乎完全支持msgraph和office 365 rest api。
- 每个api之间的良好抽象层。更改API(图形与Office365),不要担心API的内部实现。
- 完全支持OAuth,自动处理刷新令牌。
- 本地日期时间和服务器日期时间之间的自动处理。使用您的本地日期时间并让此库完成其余工作。
- 轻松地在不同资源之间切换:访问共享邮箱、其他用户资源、SharePoint资源等。
- 通过自动处理未来请求的自定义迭代器提供分页支持。请求无限物品!
- 帮助您构建自定义OData查询(筛选、排序、选择和搜索)的查询助手。
- 可以创建和构建模块化的apicomponents以实现进一步的功能。
这个项目也是我们的学习资源。这是一个列表,列出了在这个项目中使用的不太常见的python习惯用法:
- 新的解包技术:
def method(argument,*,with_name=none,**other_params):
- 枚举:
来自枚举导入枚举
- 工厂范例
- 包装组织
- 时区转换和时区感知日期时间
- 等等(见代码!)
下面是一个维基……
目录
安装
o365在pypi.org上提供。只需运行pip install o365即可安装。
要求:>;=python 3.4
pip安装的项目依赖项:
- 请求
- 请求OAuthlib
- beatifulsoup4
- 字符串大小写
- python dateutil
- TZLocal
- 皮兹
用法
使用此库的第一步是注册应用程序并检索auth令牌。请参见认证。
强烈建议在进行身份验证时添加"脱机访问"权限并请求此作用域。否则,库只能访问用户资源1小时。
通过检索和存储访问令牌,您将能够对服务执行API调用。
检查身份验证和使用库的常见模式如下:
scopes=['my_required_scopes']account=Account(credentials)ifnotaccount.is_authenticated:# will check if there is a token and has not expired# ask for a login# console based authentication See Authentication for other flowsaccount.authenticate(scopes=scopes)# now we are autheticated# use the library from now on# ...
身份验证
您只能使用OAuth进行身份验证2018年11月1日,作为Microsoft不赞成使用的基本身份验证。
- OAuth身份验证:使用用户同意后提供的身份验证令牌。
连接类处理身份验证。
OAuth身份验证
本节使用Microsoft Graph协议进行说明,几乎同样适用于Office 365 Rest API。
验证步骤
要使用OAuth,首先需要在azure应用程序注册处注册应用程序
- 登录azure门户(应用程序注册)
- 创建应用程序。设置名称。
- 在"支持的帐户类型"中,如果您使用的是个人帐户,请选择"任何组织目录中的帐户和个人Microsoft帐户(如Skype、Xbox、Outlook.com)。
- 将重定向uri(web)设置为:
https://login.microsoftonline.com/common/oauth2/nativeclient
并单击register。这是此库使用的默认重定向uri,但如果需要,可以使用其他任何重定向uri。 - 写下应用程序(客户端)ID。您需要这个值。
- 在"证书和机密"下,生成新的客户端机密。最好将过期时间设置为从不。
- 记下现在创建的客户端机密的值。稍后将隐藏。
- 在"API权限"下,添加您想要的Microsoft Graph的委派权限(请参阅作用域),例如,要读取和发送电子邮件,请使用:
- mail.readwrite
- mail.send
- 用户。阅读
- 强烈建议添加"脱机访问"权限。否则,您必须每小时重新验证一次。 < > >
< > >
然后,您需要第一次登录以获得访问令牌,方法是同意应用程序访问其所需的资源。
要进行身份验证(登录),您可以遵循不同的流程(见下文)。对于本例,我们将使用基于控制台的身份验证。调用
account.authenticate
并传递所需的作用域(以前在应用程序注册门户中添加的作用域)。您可以将"protocol scopes"(如:"https://graph.microsoft.com/calendars.readwrite")传递给该方法或使用"作用域帮助者"like("消息全部")。 如果传递协议作用域,则必须使用作用域使用的相同协议初始化
帐户
实例。通过使用作用域帮助程序,您可以从作用域中提取协议,并让此库为您工作。
最后,您可以将"protocol scopes"与"scope helpers"混合并匹配。 转到协议部分了解更多有关协议的信息。例如(按照前面添加的权限):
# ...account=Account(credentials)# the default protocol will be Microsoft Graphaccount.authenticate(scopes=['basic','message_all'])# 'basic' adds: 'offline_access' and 'https://graph.microsoft.com/User.Read'# 'message_all' adds: 'https://graph.microsoft.com/Mail.ReadWrite' and 'https://graph.microsoft.com/Mail.Send'
此方法调用将打印一个URL,用户必须访问该URL才能在所需权限上同意应用。
然后,用户必须访问此url并同意该应用程序。当同意后,页面将用一个名为"code"的URL查询参数重拨到:"https://login.microsoftonline.com/common/oauth2/nativeclient"(您可以更改此设置)。
然后,用户必须复制生成的页面url并将其粘贴回控制台。 如果登录尝试成功,该方法将返回true。
注意:必须保护访问(和刷新)令牌不受未经授权的用户的影响。
此时,您将存储一个访问令牌,该令牌将在使用api时提供有效凭据。如果你更改请求的作用域,则当前令牌将不起作用,您将需要用户再次同意该应用程序才能访问请求的新作用域。
< > >
访问令牌仅持续60分钟,但应用程序将通过刷新令牌自动请求新的访问令牌(如果且仅当您添加了"脱机访问"权限),但请注意,刷新令牌仅持续90天。因此,您必须在使用之前使用它,否则您将需要再次请求新的访问令牌(用户不需要新的同意,只需登录即可)。
如果您的应用程序需要在没有用户交互和没有与API交互的情况下工作90天以上,则必须在90天过去之前定期调用
connection.refresh\u token
。 < > >基于控制台的身份验证:
您可以使用控制台进行身份验证。实现这一点的最佳方法是使用
account
类的authenticate
方法。account=Account(credentials)account.authenticate(scopes=['basic','message_all'])
authenticate
方法将在控制台中打印一个URL,您必须访问该URL才能实现身份验证。 然后在访问链接并进行身份验证之后,您必须将生成的url粘贴回控制台中。 方法将返回true
并在成功时打印消息。提示:使用MacOS时,控制台限制为1024个字符。如果你的url有多个作用域,它可以超过这个限制。解决这个问题。只需将readline导入脚本的顶部即可。
基于Web应用的身份验证:
您可以按照以下步骤在Web环境中对用户进行身份验证:
- 首先确保使用适当的令牌后端来存储身份验证令牌(请参阅下面的令牌存储)。
- 从处理程序将用户重定向到Microsoft登录URL。提供回调。存储状态。
- 从回调处理程序中,使用状态和其他数据完成身份验证。 < > >
下面的示例是使用烧瓶完成的。
@route('/stepone')defauth_step_one()callback='my absolute url to auth_step_two_callback'account=Account(credentials)url,state=account.con.get_authorization_url(requested_scopes=my_scopesredirect_uri=callback)# the state must be saved somewhere as it will be needed latermy_db.store_state(state)# example...returnredirect(url)@route('/steptwo')defauth_step_two_callback():account=Account(credentials)# retreive the state saved in auth_step_onemy_saved_state=my_db.get_state()# example...# rebuild the redirect_uri used in auth_step_onecallback='my absolute url to auth_step_two_callback'result=account.con.request_token(request.url,state=my_saved_state,redirect_uri=callback)# if result is True, then authentication was succesful # and the auth token is stored in the token backendifresult:returnrender_template('auth_complete.html')# else ....
其他身份验证流:
最后,您可以使用
连接来配置任何其他流。获取"授权"URL
和连接。根据需要请求"令牌"。
< > >filesystemtokenbackend
(默认后端):存储和检索文件系统中的令牌。令牌存储为文件。firestoretokenbackend
:存储和检索来自google firestore数据存储的令牌。标记作为文档存储在集合中。子类
basetokenbackend
执行以下方法:
\uu init\uu
(不要忘记调用super()。\uu init\uu
)获取令牌
:这应该设置self.token
并返回令牌
实例或无保存令牌
:这应该将自身令牌
存储在所需的后端。- 也可以实现:
检查令牌
和删除令牌
< > >msgraphprotocol
使用Microsoft Graph APImsoffice365protocol
使用Office 365 API- 这是Microsoft推荐的协议。
- 它可以通过Office 365访问更多资源(例如OneDrive)
- 它可以发送附件高达150MB的电子邮件。msgraph在每次请求时只允许4MB。
- "我":已经同意的用户。每个协议的默认值。
- '用户:user@domain.com':您有权使用的共享邮箱或用户帐户。如果您不提供"user:"无论如何都会被推断出来。
- 'sharepoint:sharepoint站点id':一个sharepoint站点id。
- "组:组站点ID":Office365组ID。
- 所需的基本权限是users.readbasic.all(限制信息)
- 完全权限为users.read.all,但需要管理员同意。
- 工作表
- 范围和名称范围
- 表格、表格列和表格行
- 范围格式(到格式范围)
- 图表(暂时不提供)
不同的身份验证流
要简化身份验证,基本上可以使用不同的方法:
权限和作用域:
当使用oauth时,您将创建一个应用程序,并允许其用户访问和使用某些资源。 然后,用户可以通过向OAuth提供程序提供作用域来请求对其中一个或多个资源的访问。
例如,应用程序可以具有calendar.read、mail.readwrite和mail.send权限,但应用程序只能请求访问mail.readwrite和mail.send权限。
这是通过向帐户提供作用域来实现的。authenticate
方法或是向这样的连接实例提供作用域:
fromO365importConnectioncredentials=('client_id','client_secret')scopes=['https://graph.microsoft.com/Mail.ReadWrite','https://graph.microsoft.com/Mail.Send']con=Connection(credentials,scopes=scopes)
作用域实现取决于所使用的协议。因此,通过使用协议数据,您可以自动设置所需的作用域:
您可以使用如下协议获得与以前相同的作用域:
protocol_graph=MSGraphProtocol()scopes_graph=protocol.get_scopes_for('message all')# scopes here are: ['https://graph.microsoft.com/Mail.ReadWrite', 'https://graph.microsoft.com/Mail.Send']protocol_office=MSOffice365Protocol()scopes_office=protocol.get_scopes_for('message all')# scopes here are: ['https://outlook.office.com/Mail.ReadWrite', 'https://outlook.office.com/Mail.Send']con=Connection(credentials,scopes=scopes_graph)
但是,使用帐户时,所有协议/作用域的内容都可以自动寻址。authenticate
方法。
令牌存储:
验证时,您将检索OAuth令牌。如果您不想一次性访问,则必须将令牌存储在某处。 O365不假设令牌存储在何处,并试图从库使用的角度提取令牌。
您可以通过使用正确的令牌后端来选择存储令牌的位置和方式。
注意:必须保护访问(和刷新)令牌不受未经授权的用户的影响。
要存储令牌,必须提供正确配置的令牌后端。 实际上只有两个实现(但是您可以更轻松地实现CookieBackend等功能:
例如,使用文件系统令牌后端:
fromO365importAccount,FileSystemTokenBackendcredentials=('id','secret')# this will store the token under: "my_project_folder/my_folder/my_token.txt".# you can pass strings to token_path or Path instances from pathlibtoken_backend=FileSystemTokenBackend(token_path='my_folder',token_filename='my_token.txt')account=Account(credentials,token_backend=token_backend)# This account instance tokens will be stored on the token_backend configured before.# You don't have to do anything more# ...
现在使用相同的示例使用firestoretokenbackend:
fromO365importAccountfromO365.utilsimportFirestoreBackendfromgoogle.cloudimportfirestorecredentials=('id','secret')# this will store the token on firestore under the tokens collection on the defined doc_id.# you can pass strings to token_path or Path instances from pathlibuser_id='whatever the user id is'# used to create the token document iddocument_id='token_{}'.format(user_id)# used to uniquely store this tokentoken_backend=FirestoreBackend(client=firestore.Client(),collection='tokens',doc_id=document_id)account=Account(credentials,token_backend=token_backend)# This account instance tokens will be stored on the token_backend configured before.# You don't have to do anything more# ...
实现新的令牌后端:
协议
协议处理不同api之间通信的各个方面。 默认情况下,此项目使用Office 365 API或Microsoft Graph API。 但是,只要实现所需的协议,就可以使用许多其他Microsoft API。
您可以使用其中一个:
两种协议都相似,但请考虑以下几点:
使用 使用 您可以通过继承 您可以这样实例化协议: 每个api端点都需要一个资源。这通常定义数据的所有者。
每个协议都默认为资源"me"。me'是已经同意的用户,但您可以通过向协议构造函数提供不同的默认资源来更改此行为。 例如,访问共享邮箱时: 但这可以在任何时候完成。例如在协议级别: 不必定义在帐户或协议级别使用的资源,您可以按如下方式为每个用例提供它: 通常您将使用默认的"我"资源,但您也可以使用以下资源之一: 通常您只需要使用 但您也只能使用您想要的部件。 例如,而不是: 您只能使用所需的部件: 实现自定义类也很容易。 从 邮箱将邮件和电子邮件文件夹的功能分组。 这些是使用 表示电子邮件邮箱中的文件夹。 您可以通过请求子文件夹或按名称筛选来获取邮箱中的任何文件夹。 一个包含所有数据和方法的电子邮件对象。 创建草稿邮件非常简单: 使用保存的电子邮件也很容易: 您可以执行以下操作发送内联图像: 您可以通过执行以下操作来检索邮件标题: 请注意,只有添加到select语句中的消息头和其他属性才会出现。 通讯录组联系人文件夹和联系人的功能。Microsoft API不支持Outlook通讯组。 这些是使用 表示Office 365中"联系人"部分中的文件夹。
addressbook类表示父文件夹(它本身就是一个文件夹)。 您可以通过请求子文件夹或按名称筛选来获取通讯簿中的任何文件夹。 Office 365 API(或MS Graph API)没有outlook全局地址列表等概念。
但是你不能用他可以访问组织内的所有用户。 未经管理员同意,您只能访问每个用户的一些属性,如姓名和电子邮件,以及更多。
您可以按姓名搜索或检索指定完整电子邮件的联系人。 搜索全局地址列表(用户API): 通过电子邮件检索联系人: 从 从 日历和事件功能在 a 这些是处理 使用 使用 重要的是要知道,当使用 使用Microsoft Graph中的共享日历时存在一些已知问题。 驱动器将允许您使用文件夹和文件。 这些是使用 文件和文件夹都是驱动项。图像和照片都是文件,但照片也是图像。它们都有不同的方法和性质。
使用"is-xxxx"时请小心。 复制driveitem时,api可以返回该项的直接副本或指向将通知复制操作进度的资源的指针。 您还可以使用共享权限: 您还可以: 您可以与存储在OneDrive或SharePoint文档库中的新Excel文件(.xlsx)进行交互。
您可以检索工作簿、工作表、表,甚至单元数据。
您也可以在线写入任何Excel。 要使用Excel文件,首先必须使用OneDrive或SharePoint功能检索 使用 这是更新单元格值的方式: 与Excel交互时,可以使用工作簿会话以持久或非持久的方式有效地进行更改。
如果您对excel文件执行多次更改,则此会话将变得有用。 默认情况是以持久的方式使用会话。
会话在一段时间不活动后过期。使用持久会话时,旧会话过期时将自动创建新会话。 但是,您可以在创建 创建 一些示例: 为给定范围设置格式 自动调整列: 从表中获取值: sharepoint api已经完成,但是还没有文档。查看sharepoint.py文件以获得深入了解。 这是使用 计划器api已经完成,但是还没有文档。请查看planner.py文件以获取详细信息。 计划器功能需要管理员权限。 当使用某些方法时,您可能请求的项多于api在单个api调用中返回的项。
在这种情况下,API返回一个"下一个链接"URL,您可以从中提取更多数据。 在这种情况下,这个库中的方法将返回一个 例如: 使用某些方法时,您不仅可以指定限制选项(要返回的项目数),还可以指定批处理选项。
此选项将指示批量向api请求数据的方法,直到达到限制或数据被消耗为止。
当你希望优化内存或网络延迟。 例如: 使用Office 365 API时,可以对某些字段进行筛选、排序、选择、展开或搜索。
使用开放数据协议(OData)时,这种过滤是乏味的。
每个 例如: 还可以使用"select"指定要检索的特定数据:
你也可以搜索内容。如图中所示: 您当前只能搜索邮件和个人收藏。$search请求最多返回250个结果。您不能在搜索请求中使用$filter或$orderby。 如果您对邮件执行搜索,并且只指定了一个不带特定邮件属性的值,则将在"发件人"、"主题"和"正文"的默认搜索属性上执行搜索。 每当出现请求错误时,连接对象将引发异常。
然后将捕获异常并将其记录到stdout中,并显示消息,返回falsy(none、false、[]等) httperrors 4xx(错误请求)和5xx(内部服务器错误)被视为异常,也由连接引发。
您可以告诉msgraphprotocol的原因
msoffice365协议的原因
帐户
类使用的默认协议是msgraphprotocol
协议来实现自己的协议,以便与其他Microsoft API进行通信。
fromO365importAccountcredentials=('client_id','client_secret')account=Account(credentials)m=account.new_message()m.to.add('to_example@example.com')m.subject='Testing!'m.body="George Best quote: I've stopped drinking, but only while I'm asleep."m.send()
0
资源:
fromO365importAccountcredentials=('client_id','client_secret')account=Account(credentials)m=account.new_message()m.to.add('to_example@example.com')m.subject='Testing!'m.body="George Best quote: I've stopped drinking, but only while I'm asleep."m.send()
1
fromO365importAccountcredentials=('client_id','client_secret')account=Account(credentials)m=account.new_message()m.to.add('to_example@example.com')m.subject='Testing!'m.body="George Best quote: I've stopped drinking, but only while I'm asleep."m.send()
2
fromO365importAccountcredentials=('client_id','client_secret')account=Account(credentials)m=account.new_message()m.to.add('to_example@example.com')m.subject='Testing!'m.body="George Best quote: I've stopped drinking, but only while I'm asleep."m.send()
3
账户类别和模块性
account
类。这是所有功能的包装。fromO365importAccountcredentials=('client_id','client_secret')account=Account(credentials)m=account.new_message()m.to.add('to_example@example.com')m.subject='Testing!'m.body="George Best quote: I've stopped drinking, but only while I'm asleep."m.send()
4
fromO365importAccountcredentials=('client_id','client_secret')account=Account(credentials)m=account.new_message()m.to.add('to_example@example.com')m.subject='Testing!'m.body="George Best quote: I've stopped drinking, but only while I'm asleep."m.send()
5
a继承piccomponent
,定义端点,并使用连接发出请求。如果需要,还可以从协议继承以处理与api服务器的不同通信方面。fromO365importAccountcredentials=('client_id','client_secret')account=Account(credentials)m=account.new_message()m.to.add('to_example@example.com')m.subject='Testing!'m.body="George Best quote: I've stopped drinking, but only while I'm asleep."m.send()
6
邮箱
邮箱
和邮件
类所需的作用域。 < /广告><正文>原始范围 包含在范围帮助程序中
说明
邮件。阅读
邮箱 只阅读我的邮箱 邮件、阅读、共享
邮箱共享
只读取其他用户/共享邮箱 发送邮件
消息发送,消息全部发送
仅发送消息 邮件.发送.共享 消息发送共享,消息全部共享
仅以其他用户/共享邮箱的身份发送邮件 邮件.读写 全部信息 在我的邮箱中阅读和保存邮件 邮件.读写.共享 消息共享
在另一个用户/共享邮箱中阅读和保存邮件 fromO365importAccountcredentials=('client_id','client_secret')account=Account(credentials)m=account.new_message()m.to.add('to_example@example.com')m.subject='Testing!'m.body="George Best quote: I've stopped drinking, but only while I'm asleep."m.send()
7
电子邮件文件夹
fromO365importAccountcredentials=('client_id','client_secret')account=Account(credentials)m=account.new_message()m.to.add('to_example@example.com')m.subject='Testing!'m.body="George Best quote: I've stopped drinking, but only while I'm asleep."m.send()
8
消息
fromO365importAccountcredentials=('client_id','client_secret')account=Account(credentials)m=account.new_message()m.to.add('to_example@example.com')m.subject='Testing!'m.body="George Best quote: I've stopped drinking, but only while I'm asleep."m.send()
9
scopes=['my_required_scopes']account=Account(credentials)ifnotaccount.is_authenticated:# will check if there is a token and has not expired# ask for a login# console based authentication See Authentication for other flowsaccount.authenticate(scopes=scopes)# now we are autheticated# use the library from now on# ...
0
发送内联图像
scopes=['my_required_scopes']account=Account(credentials)ifnotaccount.is_authenticated:# will check if there is a token and has not expired# ask for a login# console based authentication See Authentication for other flowsaccount.authenticate(scopes=scopes)# now we are autheticated# use the library from now on# ...
1
检索邮件头
scopes=['my_required_scopes']account=Account(credentials)ifnotaccount.is_authenticated:# will check if there is a token and has not expired# ask for a login# console based authentication See Authentication for other flowsaccount.authenticate(scopes=scopes)# now we are autheticated# use the library from now on# ...
2
通讯录
地址簿和
联系人类所需的作用域。
< /广告><正文>原始范围 包含在范围帮助程序中
说明
联系人。阅读
通讯录 只阅读我的个人联系人 联系人。阅读。共享
通讯簿共享
只读取其他用户/共享邮箱联系人 联系人。读写 通讯簿全部 阅读和保存个人联系人 联系人。读写。共享 通讯簿全部共享
从其他用户/共享邮箱读取和保存联系人 用户.readbasic.all 用户 只从我的组织的用户(user.read.all需要管理员同意)中读取基本属性。 联系人文件夹
scopes=['my_required_scopes']account=Account(credentials)ifnotaccount.is_authenticated:# will check if there is a token and has not expired# ask for a login# console based authentication See Authentication for other flowsaccount.authenticate(scopes=scopes)# now we are autheticated# use the library from now on# ...
3
全球地址列表
scopes=['my_required_scopes']account=Account(credentials)ifnotaccount.is_authenticated:# will check if there is a token and has not expired# ask for a login# console based authentication See Authentication for other flowsaccount.authenticate(scopes=scopes)# now we are autheticated# use the library from now on# ...
4
scopes=['my_required_scopes']account=Account(credentials)ifnotaccount.is_authenticated:# will check if there is a token and has not expired# ask for a login# console based authentication See Authentication for other flowsaccount.authenticate(scopes=scopes)# now we are autheticated# use the library from now on# ...
5
联系人
地址簿
实例返回的所有内容都是一个联系人
实例。
联系人将所有信息存储为属性通讯簿中创建联系人
scopes=['my_required_scopes']account=Account(credentials)ifnotaccount.is_authenticated:# will check if there is a token and has not expired# ask for a login# console based authentication See Authentication for other flowsaccount.authenticate(scopes=scopes)# now we are autheticated# use the library from now on# ...
6
日历
schedule
对象中分组。schedule
实例可以列出和创建日历。它还可以在默认用户日历上列出或创建事件。
要使用其他日历,请使用日历
实例。
计划
、日历
和事件
类所需的作用域。 < /广告><正文>原始范围 包含在范围帮助程序中
说明
日历。阅读
日历 只阅读我的个人日历 日历。读取。共享 日历共享
只读取其他用户/共享邮箱日历 日历。读写 全部日历 阅读和保存个人日历 日历。读写。共享 全部共享日历 从其他用户/共享邮箱读取和保存日历 计划
实例:
scopes=['my_required_scopes']account=Account(credentials)ifnotaccount.is_authenticated:# will check if there is a token and has not expired# ask for a login# console based authentication See Authentication for other flowsaccount.authenticate(scopes=scopes)# now we are autheticated# use the library from now on# ...
7
日历
实例:
scopes=['my_required_scopes']account=Account(credentials)ifnotaccount.is_authenticated:# will check if there is a token and has not expired# ask for a login# console based authentication See Authentication for other flowsaccount.authenticate(scopes=scopes)# now we are autheticated# use the library from now on# ...
8
< Buff行情>include\recursive=true
查询事件(这是默认值)时,必须提供一个具有已定义的开始和结束属性的查询参数。
与使用include\recursive=false
不同,这些属性不会根据您在查询上设置的操作(大于等于、小于等)筛选数据,而只是筛选所提供的开始日期时间和结束日期时间之间的事件开始日期时间。OneDrive
存储类在sharepoint中处理围绕一个驱动器和文档库存储的所有功能。
存储
实例允许检索驱动器
实例,这些实例处理所选存储中的所有文件和文件夹。
通常您只需要使用默认驱动器。但是
存储
实例可以处理多个驱动器。存储、
驱动器和
驱动器项类所需的作用域。
< /广告><正文>原始范围 包含在范围帮助程序中
说明
文件。读取
只读取我的文件 文件。全部读取 OneDrive 只看美国所有的文件ER可以访问 文件。读写 读取和保存我的文件 文件.readwrite.all 所有OneDrive 要读取和保存用户可以访问的所有文件 scopes=['my_required_scopes']account=Account(credentials)ifnotaccount.is_authenticated:# will check if there is a token and has not expired# ask for a login# console based authentication See Authentication for other flowsaccount.authenticate(scopes=scopes)# now we are autheticated# use the library from now on# ...
9
# ...account=Account(credentials)# the default protocol will be Microsoft Graphaccount.authenticate(scopes=['basic','message_all'])# 'basic' adds: 'offline_access' and 'https://graph.microsoft.com/User.Read'# 'message_all' adds: 'https://graph.microsoft.com/Mail.ReadWrite' and 'https://graph.microsoft.com/Mail.Send'
0
# ...account=Account(credentials)# the default protocol will be Microsoft Graphaccount.authenticate(scopes=['basic','message_all'])# 'basic' adds: 'offline_access' and 'https://graph.microsoft.com/User.Read'# 'message_all' adds: 'https://graph.microsoft.com/Mail.ReadWrite' and 'https://graph.microsoft.com/Mail.Send'
1
# ...account=Account(credentials)# the default protocol will be Microsoft Graphaccount.authenticate(scopes=['basic','message_all'])# 'basic' adds: 'offline_access' and 'https://graph.microsoft.com/User.Read'# 'message_all' adds: 'https://graph.microsoft.com/Mail.ReadWrite' and 'https://graph.microsoft.com/Mail.Send'
2
excel
文件
实例。
工作簿和Excel相关类所需的作用域与OneDrive使用的作用域相同。
# ...account=Account(credentials)# the default protocol will be Microsoft Graphaccount.authenticate(scopes=['basic','message_all'])# 'basic' adds: 'offline_access' and 'https://graph.microsoft.com/User.Read'# 'message_all' adds: 'https://graph.microsoft.com/Mail.ReadWrite' and 'https://graph.microsoft.com/Mail.Send'
3
工作簿会话
工作簿
实例时更改此设置:
# ...account=Account(credentials)# the default protocol will be Microsoft Graphaccount.authenticate(scopes=['basic','message_all'])# 'basic' adds: 'offline_access' and 'https://graph.microsoft.com/User.Read'# 'message_all' adds: 'https://graph.microsoft.com/Mail.ReadWrite' and 'https://graph.microsoft.com/Mail.Send'
4
可用对象
工作簿
实例后,您将可以访问以下对象:# ...account=Account(credentials)# the default protocol will be Microsoft Graphaccount.authenticate(scopes=['basic','message_all'])# 'basic' adds: 'offline_access' and 'https://graph.microsoft.com/User.Read'# 'message_all' adds: 'https://graph.microsoft.com/Mail.ReadWrite' and 'https://graph.microsoft.com/Mail.Send'
5
# ...account=Account(credentials)# the default protocol will be Microsoft Graphaccount.authenticate(scopes=['basic','message_all'])# 'basic' adds: 'offline_access' and 'https://graph.microsoft.com/User.Read'# 'message_all' adds: 'https://graph.microsoft.com/Mail.ReadWrite' and 'https://graph.microsoft.com/Mail.Send'
6
# ...account=Account(credentials)# the default protocol will be Microsoft Graphaccount.authenticate(scopes=['basic','message_all'])# 'basic' adds: 'offline_access' and 'https://graph.microsoft.com/User.Read'# 'message_all' adds: 'https://graph.microsoft.com/Mail.ReadWrite' and 'https://graph.microsoft.com/Mail.Send'
7
sharepoint
sharepoint
和site
类所需的作用域。 < /广告><正文>原始范围 包含在范围帮助程序中
说明
站点。全部阅读 sharepoint 只阅读网站、列表和项目 站点。读写。全部 SharePoint下载 阅读和保存网站、列表和项目 计划者
实用程序
分页
分页
对象,该对象将所有这些抽象为一个迭代器。
分页对象将在需要时立即请求"下一个链接"。# ...account=Account(credentials)# the default protocol will be Microsoft Graphaccount.authenticate(scopes=['basic','message_all'])# 'basic' adds: 'offline_access' and 'https://graph.microsoft.com/User.Read'# 'message_all' adds: 'https://graph.microsoft.com/Mail.ReadWrite' and 'https://graph.microsoft.com/Mail.Send'
8
# ...account=Account(credentials)# the default protocol will be Microsoft Graphaccount.authenticate(scopes=['basic','message_all'])# 'basic' adds: 'offline_access' and 'https://graph.microsoft.com/User.Read'# 'message_all' adds: 'https://graph.microsoft.com/Mail.ReadWrite' and 'https://graph.microsoft.com/Mail.Send'
9
查询帮助程序
apicomponent
(例如mailbox
)都实现一个新的查询方法,该方法将返回一个查询
实例。
这个查询
实例可以很容易地处理过滤、排序、选择、扩展和搜索。
account=Account(credentials)account.authenticate(scopes=['basic','message_all'])
0
account=Account(credentials)account.authenticate(scopes=['basic','message_all'])
1
account=Account(credentials)account.authenticate(scopes=['basic','message_all'])
2
请求错误处理
连接不引发http错误,方法是传递
raise-http-errors=false
(默认为true)。推荐PyPI第三方库