Mar*_*ino 6 python-3.x microsoft-graph-api
我正在使用 python requests-oauthlib 包连接到 Microsoft Graph。我正在使用 OAuth 2.0 客户端凭据流程。
下面的简化代码工作得很好:
from oauthlib.oauth2 import BackendApplicationClient
from requests_oauthlib import OAuth2Session
client = BackendApplicationClient(client_id='myclientid')
token_url = "https://login.microsoftonline.com/mydomain.onmicrosoft.com/oauth2/v2.0/token"
msgraph = OAuth2Session(client=client)
msgraph.fetch_token(
token_url = token_url,
client_secret = 'myclientsecret',
scope='https://graph.microsoft.com/.default')
response = msgraph.get(
url="https://graph.microsoft.com/v1.0/users/user@mydomain.com/messages")
Run Code Online (Sandbox Code Playgroud)
虽然这有效,但在这种情况下,承载访问令牌的有效期仅为 1 小时。requests-oauthlib 包支持刷新令牌,但它似乎仅限于带有单独刷新令牌的令牌类型。与 Microsoft Graph 一起使用的客户端凭据流仅发出 access_token。
所以我的问题是:
| 归档时间: |
|
| 查看次数: |
3079 次 |
| 最近记录: |