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

Calendar events not fetching | Microsoft Graph API | Using premium personal outlook accounts

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

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

请帮忙解决。提前谢谢你:)

我附上我的 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

使用 'Oauth' class 或 python 来传递您的所有令牌并添加详细信息,例如客户端 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 headers
print(eventResponce.data)