未获取日历事件 | 微软图形 API | 使用高级个人 outlook 帐户

我正在尝试从我的个人高级 Outlook 帐户中获取日历事件。它不是工作帐户。 我订阅了 Office 365。使用相同的方法,我设置了 Azure actuve 目录,我在其中添加了我的 python Web 应用程序,授予了该应用程序所需的所有权限。通过 Web 应用程序访问 API 时,我能够获取配置文件详细信息、用户和所有内容,但无法获取与事件、日历等相关的数据。 我收到此错误- “消息”:“租户 guid \u00* 的租户******b5d- *9-4b -b 1-c 5c***2ec8\u0027 不存在。”


我在 msdn 和 stackoverflow 上查看了很多解决方案,但每个人都告诉我要获得一个高级帐户,但我这样做了,但问题仍然没有解决。


请帮助解决同样的问题。先感谢您 :)


我附上我的app.config文件的副本供您参考。


import os


CLIENT_SECRET = "client secret key" 


AUTHORITY = "https://login.microsoftonline.com/tenant id"


CLIENT_ID = "client id"


REDIRECT_PATH = "/getAToken"    


ENDPOINT =ENDPOINT = 'https://graph.microsoft.com/v1.0/users/{my id}/events

# I also tried 'ENDPOINT = ' 'https://graph.microsoft.com/v1.0/users/{my id}/calendar/events''


SCOPE = ["User.ReadBasic.All"]


SESSION_TYPE = "filesystem"  # So token cache will be stored in server-side session


拉丁的传说
浏览 120回答 1
1回答

隔江千里

使用 python 的“Oauth”类传递所有令牌并添加详细信息,如客户端 ID、客户端密码等。类似这样的东西——(注意配置文件包含我上面提到的所有详细信息。)OAUTH = OAuth(APP)MSGRAPH = OAUTH.remote_app(    'microsoft',    consumer_key=config.CLIENT_ID,    consumer_secret=config.CLIENT_SECRET,    request_token_params={'scope': config.SCOPES},    base_url=config.RESOURCE + config.API_VERSION + '/',    request_token_url=None,    access_token_method='POST',    access_token_url=config.AUTHORITY_URL + config.TOKEN_ENDPOINT,    authorize_url=config.AUTHORITY_URL + config.AUTH_ENDPOINT)我的配置文件:CLIENT_ID = 'put here'CLIENT_SECRET = 'put here'REDIRECT_URI = 'http://localhost:5000/login/authorized'AUTHORITY_URL = 'https://login.microsoftonline.com/common'AUTH_ENDPOINT = '/oauth2/v2.0/authorize'TOKEN_ENDPOINT = '/oauth2/v2.0/token'RESOURCE = 'https://graph.microsoft.com/'API_VERSION = 'v1.0'SCOPES = ['User.Read', 'Mail.Send', 'Files.ReadWrite','Calendars.Read', 'Calendars.ReadWrite'] 现在您可以这样调用获取事件:eventResponse = MSGRAPH.get('me/events',headers=request_headers()) #request_headers() return all the requeried headersprint(eventResponce.data)
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python