python - 我正在尝试使用 python 脚本从 Outlook 中获取日历。我收到无效的范围值错误。我错过了什么?
问题描述
我正在尝试使用 Python 脚本在 Outlook 中获取我的共享日历。我是一年级计算机科学专业和初学者。我认为将我所有的日历事件都打印到终端会很好,我认为这个小活动会让我受益。但是,在将登录门户链接粘贴到 chrome 后,我的浏览器中出现无效范围值错误。我已将我认为需要的所有权限和平台配置添加到 Azure?我错过了什么?
浏览器错误:
https://login.microsoftonline.com/common/oauth2/nativeclient?error=invalid_scope&error_description=The%20provided%20value%20for%20the%20input%20parameter%20%27scope%27%20is%20not%20valid.%20The%20scope%20%27Calendars.Read.Shared%27%20is%20not%20valid.&state=iC6gDfcX1C7BCPfsrvdHpp4a7kzcRr
终端输出:
Visit the following url to give consent:
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?response_type=code&client_id=844ecf49-96c1-422d-a611-b7bad4882745&redirect_uri=https%3A%2F%2Flogin.microsoftonline.com%2Fcommon%2Foauth2%2Fnativeclient&scope=Calendars.Read.Shared&state=iC6gDfcX1C7BCPfsrvdHpp4a7kzcRr&access_type=offline
Paste the authenticated url here:
这是我的代码:
from O365 import Account, MSGraphProtocol
CLIENT_ID = '844ecf49-96c1-422d-a611-b7bad4882745'
SECRET_ID = 'q~-n~w9_kTb6mTIrbmcA2-139rqiSph4n_'
SCOPE = ["Calendars.Read.Shared"]
credentials = (CLIENT_ID, SECRET_ID)
protocol = MSGraphProtocol()
account = Account(credentials, protocol=protocol)
if account.authenticate(scopes=SCOPE):
print("Authenticated!")
schedule = account.schedule()
calendar = schedule.get_default_calendar()
events = calendar.get_events(include_recurring=False)
for event in events:
print(event)
解决方案
推荐阅读
- jquery - Bootstrap 模态背景未隐藏
- python - 如何使用 Numba 在 SciPy 中使用任意数量的变量和参数执行多重集成?
- r - R 新手,需要帮助编码功能和理解错误
- sql-server - Azure SQL 数据库 DTU 最大化 - 由于大型数据库?
- javascript - enablejsapi 作为 iframe 元素的属性
- xpath - 使用 Ansible xml 模块从 XML 文件中获取特定属性
- sql - 参数必须是在phpmyadmin中实现Countable的数组或对象
- macos - 尝试安装 Polymer 2 CLI
- c++ - 在 MPI 循环中传递数据
- javascript - 两个 JS 对象,从第一个对象中获取第二个对象中缺少的值