小编Ren*_*ira的帖子

即使用户在用户端点上列出,“租户 GUID 的租户不存在”?

我正在尝试与 Outlook 的 API 集成(更具体地说,我想列出用户的联系人,并能够对他们执行一些 CRUD)。

我在 Azure 上创建了一个 Azure 帐户、一个 Office 365 开发人员帐户和一个应用程序。

我可以使用登录端点获取访问令牌,如下所示:

https://login.microsoftonline.com/<tenant_id>/oauth2/token
Run Code Online (Sandbox Code Playgroud)

我也可以/users使用不记名令牌通过端点检索用户列表或获取用户的详细信息。“获取用户”方法的结果返回如下内容:

{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
  "businessPhones": [],
  "displayName": "Renato Oliveira",
  "givenName": "Renato",
  "jobTitle": null,
  "mail": null,
  "mobilePhone": null,
  "officeLocation": null,
  "preferredLanguage": null,
  "surname": "Oliveira",
  "userPrincipalName": "renato.company.com.br#EXT#@renatocompanycom.onmicrosoft.com",
  "id": "<user_id>"
}
Run Code Online (Sandbox Code Playgroud)

当然,这是使用在其上/users传递的端点user_id

https://graph.microsoft.com/v1.0/users/<user_id>
Run Code Online (Sandbox Code Playgroud)

但是,我无法获取该用户的联系人。当我向下面的端点发送 GET 请求时

https://graph.microsoft.com/v1.0/users/<user_id>/contacts
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

{
  "error": {
    "code": "OrganizationFromTenantGuidNotFound",
    "message": "The tenant for tenant guid '<my_active_directory_tenant_id>' does not exist.",
    "innerError": {
      "request-id": "<request_id>",
      "date": "2019-03-18T20:43:16"
    }
  } …
Run Code Online (Sandbox Code Playgroud)

rest outlook azure

8
推荐指数
1
解决办法
1万
查看次数

使用带有Express的NodeJS从MongoDB中检索数据

好了,在过去的几天里,我开始与节点搞乱(因为我觉得我应该学的东西,实际上是有用的,可能会得到我的工作).现在,我知道如何提供页面,基本路由等.尼斯.但我想学习如何查询数据库以获取信息.

现在,我正在尝试构建一个充当webcomic网站的应用程序.因此,理论上,当我输入url时,应用程序应该查询数据库http://localhost:3000/comic/<comicid>

我的app.js文件中有以下代码:

router.get('/', function(req, res) {  
    var name = getName();
    console.log(name); // this prints "undefined"

    res.render('index', {
        title: name,
        year: date.getFullYear()
    });
});

function getName(){
    db.test.find({name: "Renato"}, function(err, objs){
    var returnable_name;
        if (objs.length == 1)
        {
            returnable_name = objs[0].name;
            console.log(returnable_name); // this prints "Renato", as it should
            return returnable_name;
        }
    });
}
Run Code Online (Sandbox Code Playgroud)

通过这种设置,我可以console.log(getName())在控制台中输出"undefined",但我不知道为什么它不能获得查询在数据库中实际可以找到的唯一元素.

我试过用SO搜索,甚至用Google搜索的例子,但没有成功.

我到底该如何从对象中获取参数名称?

javascript mongodb node.js express

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

azure ×1

express ×1

javascript ×1

mongodb ×1

node.js ×1

outlook ×1

rest ×1