【问题标题】:C# web-form to obtain Access TokenC# web-form 获取访问令牌
【发布时间】:2018-02-02 14:37:17
【问题描述】:

我是 Graph API 的新手。我有以下代码来获取我已经设置的应用程序的访问令牌:

private const string _scope = "wl.skydrive_update";

private const string _clientID = "56665168-fb52-**************";

private const string _signInUrl = @"https://login.live.com/oauth20_authorize.srf?client_id={0}&redirect_uri=https:login.live.com/oauth20_desktop.srf&response_type=code&scope={1}";

当我运行它时,我得到:https://login.live.com/oauth20_authorize.srf 窗口要求我登录。 但是:

我有我的个人 Microsoft 帐户和 Business Office 365 帐户。我可以通过我的个人帐户获取访问令牌,但是当我尝试使用我的企业帐户登录(在此窗口中登录)时。它一直告诉我找不到帐户。如果是这样,那么我如何(什么 URL)从我的企业帐户中获取响应?

任何帮助,建议将不胜感激。

【问题讨论】:

    标签: c# api microsoft-graph-api onedrive


    【解决方案1】:

    请参阅getting access tokens on behalf of a user 的 Microsoft Graph 文档页面。如果您在Microsoft App registration portal 中注册您的应用程序,您可以获得适用于消费者帐户(live、hotmail 等)和企业帐户的令牌。

    适用于消费者和工作帐户的常见身份验证体验示例是https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=6731de76-14a6-49ae-97bc-6eba6914391e&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%2Fmyapp%2F&response_mode=query&scope=offline_access%20user.read%20mail.read&state=12345

    【讨论】:

      猜你喜欢
      • 2020-10-09
      • 2014-07-09
      • 1970-01-01
      • 2018-02-17
      • 2019-04-02
      • 2020-01-23
      相关资源
      最近更新 更多