Get Facebook Auth token from Azure Easy API

回眸只為那壹抹淺笑 提交于 2019-12-12 12:32:19

问题


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"));
    }
};

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


回答1:


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/

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));
        });
    }
};


来源:https://stackoverflow.com/questions/35878102/get-facebook-auth-token-from-azure-easy-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!