繁体   English   中英

使用新的Office365 API授权

[英]Authorization with new Office365 API

我已经开始尝试利用新的Office 365 API。 我有一些问题。

我已经成功检索了一个access_token,但是文档没有告诉我该怎么做。

是否有其他人成功完成了此操作,或者您可以快速阅读文档并对此有所了解吗?

谢谢

编辑:忘记链接-http : //msdn.microsoft.com/zh-cn/library/office/dn605896.aspx

根据我的研究,几乎没有使用PHP和Office365 API的文档,但是...通过使用此PHP类来处理oauth连接,我能够使用Office API:

http://www.phpclasses.org/package/7700-PHP-Authorize-and-access-APIs-using-OAuth.html

希望能帮助到你!

使用此类,您将可以像这样访问:

// Oauth to Office365
$office_oauth = new oauth_client_class;
$office_oauth->debug = true;
$office_oauth->debug_http = false;

$office_oauth->redirect_uri = 'http://' . $_SERVER['HTTP_HOST'];

$office_oauth->client_id = 'YOUR_CLIENT_ID';
$office_oauth->client_secret = 'YOUR_CLIENT_SECRET';

$office_oauth->dialog_url = 'https://login.windows.net/common/oauth2/authorize?response_type=code&client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&state={STATE}&scope={SCOPE}&resource='.UrlEncode("https://outlook.office365.com/");
$office_oauth->access_token_url = 'https://login.windows.net/common/oauth2/token';

$office_oauth->oauth_version = 2;
$office_oauth->url_parameters = 1;
$office_oauth->authorization_header = 1;
$office_oauth->exit = 0;

$office_oauth->scope = 'YOUR_SCOPES';

if (($officeSuccess = $office_oauth->Initialize())) {

    $officeSuccess = $office_oauth->Process();
    $officeSuccess = $office_oauth->Finalize($officeSuccess);
}

if ($office_oauth->exit) {
    exit;
}

调用资源时 ,访问令牌应嵌入请求中 (请找到第9个)。 因此,我猜测您需要在请求标头中提供访问令牌,例如:

context.SendingRequest2 += (s, e) => { e.RequestMessage.SetHeader("Authorization", "Bearer " + accessToken); };

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM