从Azure Easy API获取Facebook身份验证令牌 [英] Get Facebook Auth token from Azure Easy API

查看:63
本文介绍了从Azure Easy API获取Facebook身份验证令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Easy API的文档记录很少,我试图通过Azure通过针对它进行身份验证的用户获取Facebook Auth令牌,我使用以下GET创建了一个API:

Easy API are very poorly documented, I'm trying to get the Facebook Auth token from a user authenticated against it through Azure, I've created an API with the following GET:

module.exports = {
    "get": function (req, res, next) {
        res.json(req.user.getIdentity("facebook"));
    }
};

但是,天青响应无法从未定义读取属性'getIdentity'".如果在res中未定义用户,我可以从哪里得到它?

However azure responds with "cannot read property 'getIdentity' from undefined". If user is undefined in res, where can I get it from?

推荐答案

简单的API在Azure移动应用程序Node.js SDK HOWTO和API文档中进行了说明.您可以在此处找到该HOWTO:

Easy APIs is documented in the Azure Mobile Apps Node.js SDK HOWTO and within the API docs. You can find the HOWTO here: https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-node-backend-how-to-use-server-sdk/

对于特定问题,getIdentity()是基于Promise的机制.另外,您需要通过azureMobile属性访问用户对象.像这样:

As to the specific question, getIdentity() is a Promise-based mechanism. In addition, you need to access the user object through the azureMobile property. Something like:

module.exports = {
    "get": function (req, res, next) {
        req.azureMobile.user.getIdentity("facebook").then((data) => {
            res.status(200).type('application/json').json(data);
        }).catch((error) => {
            res.status(500).send(JSON.stringify(error));
        });
    }
};

这篇关于从Azure Easy API获取Facebook身份验证令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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