我已开始尝试使用新的Office 365 API。我有一些问题。
我已成功检索到access_token,但文档并没有告诉我该如何处理它。
是否还有其他人成功完成此操作,或者您是否可以快速阅读文档并对其进行了解释?
由于
修改:忘记链接 - http://msdn.microsoft.com/en-us/library/office/dn605896.aspx
答案 0 :(得分:2)
根据我的研究使用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;
}
答案 1 :(得分:1)
访问令牌应该是embedded in the request when calls the resource(请找到第9个)。所以我猜你需要在请求标题中提供访问令牌,例如:
context.SendingRequest2 += (s, e) =>
{
e.RequestMessage.SetHeader("Authorization", "Bearer " + accessToken);
};