Office 365 REST API入门 [英] Get started with Office 365 REST API

查看:235
本文介绍了Office 365 REST API入门的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确定已经询问了相关问题,但是我找不到此答案.我正在尝试为Office 365创建一个简单的ruby api包装器,但我不知道如何创建一个oauth应用程序(秘密/令牌/回调URL/.

I'm sure related questions have been asked, but I cannot find this answer. I'm trying to make a simple ruby api wrapper for Office 365, and I can't figure out how to get an oauth app created (secret/token/callback url/.

在其他所有人的oauth/api Universe中,您将转到开发人员门户并创建一个应用程序",该应用程序带有令牌和密码,可与您的通用oauth库一起使用以进行基于3条腿浏览器的身份验证.我不会碰任何Windows/.net软件来完成此操作-我们在红宝石领域.

In everyone else's oauth/api universe you head to a developer portal and create an 'Application' which comes with a token and secret to use with your generic oauth library to do the 3 legged browser based authentication. I am not going to touch any windows/.net software to accomplish this - we are in ruby land.

我认为,基于文档,我需要前往Windows azure管理门户来创建某些内容,但是我无法弄清楚到底是什么-并且我创建的内容并没有给我令牌/秘密/网址-是不是要求提供回调网址/域?

I think based on the documentation I need to head to the windows azure management portal to create something, but I can't figure out exactly what - and the things I did create are not giving me token/secret/urls - shouldn't it ask for the callback url/domain?

对于oauth gem,我正在寻找这些类型的详细信息;

For the oauth gem, I'm looking for these types of details;

def connection(credentials)
  OAuth2::Client.new(
      credentials[:client_id],
      credentials[:client_secret],
      :site => credentials[:base_url],
      :authorize_url => '/api/v1/oauth2/authorize',
      :token_url => '/api/v1/oauth2/token'
  )
end

推荐答案

[2015年8月20日更新] : http://dev.office.com/getting-started/office365apis 注册您的应用,甚至以您选择的语言创建一个入门项目.我当然建议先尝试一下,而不要执行下面概述的手动步骤.

[Update Aug 20th, 2015]: It looks like there is a new getting started experience at http://dev.office.com/getting-started/office365apis, which will help register your app, and even create a starter project in the language of your choice. I would certainly recommend trying that first, rather than going through the manual steps outlined below.

要手动注册应用程序(例如,不通过Visual Studio和 Office 365 API工具),您需要转到 https://manage.windowsazure.com/上的Azure管理门户.根据Office 365租户的SKU,您可能可以使用O365帐户登录.如果没有,您可以执行一个手动步骤,将Azure门户(例如,通过Live ID访问的门户)与O365租户相关联.让我知道您是否需要此信息.

To register apps manually (e.g., not through Visual Studio and Office 365 API Tools), you will need to go to the Azure Management portal at https://manage.windowsazure.com/. Depending on the SKU of your Office 365 tenant, You may be able to sign in with your O365 account. If not, there's a manual step you can do to associate an Azure portal (e.g., one accessed via a Live ID) with your O365 tenant. Let me know if you need this information.

假设您能够进入Active门户,在其中找到Active Directory节点,然后选择与您的O365租户相对应的目录.

Assuming you are able to get into the Active portal, find the Active Directory node there, and choose the directory that corresponds to your O365 tenant.

从此处,选择应用程序"和添加现有项"以注册您的应用程序:

From there, select "Applications" and "Add Existing" to register your app:

选择添加我的组织正在开发的应用程序" >

Choose "Add an application my organization is developing"

并填写详细信息:

And fill out the details:

创建应用程序后,请转到配置标签.在那里,您将找到客户端ID,可以生成密钥,并且(可能最重要的是)为您的应用设置访问Office 365 API的权限.

Once the application is created, go to the configure tab. There you will find the client ID, you can generate the secret, and (maybe most importantly) set permissions for your app to access the Office 365 APIs.

希望这会有所帮助!

更新:

注册该应用程序后,强烈建议您查看此处找到的示例: Web应用本地(在这种情况下, Windows 8.1)应用.这些提供了有关如何执行OAuth的出色示例,您还可以查看使用了哪些终结点来访问不同的服务(例如,还有一个用于SharePoint的Service Discovery的示例).

After registering the app, I would highly encourage you to look at the samples found here: Web app and Native (in this case, Windows 8.1) app. These have great examples of how to do OAuth, and you can also see what endpoints are used to access the different services (and an example of Service Discovery for SharePoint, for example).

在示例中,API端点&服务的资源ID信息可以在"Office365ServiceInfo.cs"文件下找到(在Web应用程序的"Models"文件夹下,在本机应用程序的"Office365"文件夹下),而auth代码可以在以下位置的"Controllers/Office365CommonController"下找到Web应用程序和本机应用程序的"Office365/Office365Helper".我也鼓励您阅读

Within the samples, the API endpoint & Resource ID information for services can be found under the "Office365ServiceInfo.cs" file (under "Models" folder in web app and "Office365" folder for native app), and the auth code can be found under "Controllers/Office365CommonController" for the web app and "Office365/Office365Helper" for the native app. I would also encourage you to read the "Exploring the Project Structure" section of this blog post.

更新2 : 可以在以下位置找到描述在Azure门户中添加和配置应用程序的MSDN文档: http: //msdn.microsoft.com/zh-CN/library/dn132599.aspx

UPDATE 2: MSDN documentation that describes adding and configuring applications in the Azure portal can be found here: http://msdn.microsoft.com/en-us/library/dn132599.aspx

更新3 : 新文档已添加到MSDN,其中涵盖了上述步骤以及如何访问O365开发站点的Azure门户:

UPDATE 3: New documentation has been added to MSDN, which covers both the steps above, and also how to get access to the Azure Portal for your O365 Dev Site: http://msdn.microsoft.com/en-us/library/office/dn736059(v=office.15).aspx

〜迈克尔

这篇关于Office 365 REST API入门的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆