我是 AWS 和 AZure 的初学者。我正在做一个 lex 机器人,它将根据代理的 Outlook 日历进行预约。我前往获取 Outlook 日历详细信息(预约的可用时间)并使用 python 库O365在 Outlook 日历上进行预约。我有客户端 ID 和密钥以及一个 api 来获取 O365 日历(从管理员那里得到)。我没有关于此 O365 功能或方法的适当文档。
from O365 import Account
credentials = ('my_client_id', 'my_client_secret')
account = Account(credentials)
if account.authenticate(scopes=['basic', 'message_all']):
print('Authenticated!')
当我运行这段代码时,我说访问一些 URL 并粘贴 API 端点。
问题: 1)我需要知道在 O365 中调用这个 api 和日历相关函数的请求类型和格式(或使用这个 O365 的适当文档) 2)这个 O365 库可以导入到 aws Lambda 中吗?会预装吗?
更新: 我得到了租户 ID,在使用自己的用户识别方法后,现在我可以进行身份验证了。但在那之后当我这样做时
from O365 import Account
import datetime as dt
credentials = ('xxxxx-0d57-49e5-xxxx-xxxxxxxx', 'xxxxx^[xxxxxxx[%')
account = Account(credentials, auth_flow_type='credentials', tenant_id='xxxxxx-e1ec-xxxxxxx-b1d9-xxxxxxxxx')
if account.authenticate():
print('Authenticated!')
schedule = account.schedule()
schedule.get_availability(['test@angkorwat.onmicrosoft.com'],dt.datetime(2019, 9, 5, 19, 45),dt.datetime(2019, 9, 10))
我收到以下错误 Resource not found for the segment 'calendar',
> C:\Users\MyPc\Desktop>python user_himself.py
> Authenticated! Client
> Error: 400 Client Error: Bad Request for url:
> https://graph.microsoft.com /v1.0/calendar/getSchedule | Error
> Message: Resource not found for the segment ' calendar'. Traceback
> (most recent call last): File "user_himself.py", line 13, in
> <module>
> schedule.get_availability(['test@angkorwat.onmicrosoft.com'],dt.datetime(
> 2019, 9, 5, 19, 45),dt.datetime(2019, 9, 10)) File
> "C:\Users\MyPc\AppData\Local\Programs\Python\Python37\lib\site-packages
> \O365\calendar.py", line 1931, in get_availability
> response = self.con.post(url, data=data) File "C:\Users\MyPc\AppData\Local\Programs\Python\Python37\lib\site-packages
> \O365\connection.py", line 725, in post
> return self.oauth_request(url, 'post', data=data, **kwargs) File "C:\Users\MyPc\AppData\Local\Programs\Python\Python37\lib\site-packages
> \O365\connection.py", line 703, in oauth_request
> return self._internal_request(self.session, url, method, **kwargs) File
> "C:\Users\Mypc\AppData\Local\Programs\Python\Python37\lib\site-packages
> \O365\connection.py", line 665, in _internal_request
> raise HTTPError('{} | Error Message: {}'.format(e.args[0], error_message), r esponse=response) from None
> requests.exceptions.HTTPError: 400 Client Error: Bad Request for url:
> https://graph.microsoft.com/v1.0/calendar/getSchedule | Error
> Message: Resource not found for the segment 'calendar'.