【问题标题】:Authentication OneDrive Python API身份验证 OneDrive Python API
【发布时间】:2017-07-15 19:35:01
【问题描述】:

我正在尝试将我的 OneDrive for business 与 Python 一起使用。

我已经安装了 onedrivesdk,现在我正在验证我的 OneDrive

提供的代码如下

import onedrivesdk

redirect_uri = 'http://localhost:8080/'
client_secret = 'your_client_secret'
client_id='your_client_id'
api_base_url='https://api.onedrive.com/v1.0/'
scopes=['wl.signin', 'wl.offline_access', 'onedrive.readwrite']

http_provider = onedrivesdk.HttpProvider()
auth_provider = onedrivesdk.AuthProvider(
http_provider=http_provider,
client_id=client_id,
scopes=scopes)

client = onedrivesdk.OneDriveClient(api_base_url, auth_provider, http_provider)
auth_url = client.auth_provider.get_auth_url(redirect_uri)

我不确定我应该提供什么 client_secret 和 client_id 才能访问我的 OneDrive

我将感谢有关从何处获取上述参数的帮助。

【问题讨论】:

  • 收到了吗?

标签: python-3.x sdk oauth-2.0 onedrive


【解决方案1】:

client_secretclient_id 是使用OAuth2 所需的两个必需参数,OAuth2 是用于授权的行业标准协议。

查看以下链接,了解如何获取与 OneDrive 访问相关的这些信息:

https://dev.onedrive.com/auth/msa_oauth.htm

Get Access Token with OneDrive API

您需要通过此链接注册您的应用程序: https://dev.onedrive.com/app-registration.htm

之后,您的应用程序将收到一些请求,并使用有效的用户凭据访问 OneDrive 帐户。

我希望它有所帮助。

【讨论】:

  • 感谢您的帮助。我已经注册了应用程序,所以现在我有一个 client_id 和密码。但是现在我如何将我的 OneDrive 关联/链接到我在 Microsoft 注册的应用程序?,非常感谢您的帮助!!!
  • 现在您必须为您的用户获取一个有效的令牌。令牌流程也在我通知的链接中进行了说明。您需要了解 OAuth2 流程。
猜你喜欢
  • 2019-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-05-25
  • 1970-01-01
  • 2014-11-30
  • 2016-03-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多