未加星标

Facebook Account Kit Tutorial - Backend Verification using Node.js

字体大小 | |
[前端(javascript) 所属分类 前端(javascript) | 发布者 店小二04 | 时间 2016 | 作者 红领巾 ] 0人收藏点击收藏
Facebook Account Kit Tutorial - Backend Verification using Node.js

by SHIVA SURYA android , android nanodegree , API , facebook No comments

Recently I have been developing secure production app using Facebook account kit for seamless authentication across mobile and web platform. Account kit is widely used in many apps such as Saavn and many other. I found that backend verification in Account kit for every request from mobile/ SPA should be handled manually by developers and no libraries available till date. so, I'mwriting this post for Indie Game and mobile developers as a reference guide.

So what's Facebook Account kit all about ?

It's seamless authentication method via OTP way to verify the user with Mobile Number and login into App without any passwords. Whereas it provides access token to verify the authenticated user in backend server without worrying about the access tokengeneration, revocation logics. It's all about securing the access token and using it over HTTPS connection while connecting between your app and backend.


Facebook Account Kit Tutorial - Backend Verification using Node.js
Facebook Account Kit Tutorial - Backend Verification using Node.js Prerequisites :

In this tutorial, we'll solely concentrate on Backend verification and authorising the legal request made by the apps.

Facebook Developer Account Good Knowledge on Node.js routeing Rest API client Good logical error handling skill How Does Account Kit works ?

When the user signup using his mobile number, he would receive the OTP via SMS Carrier from facebook server. after authenticating OTP password, the account kit sdk gives you the long live Access token or Client side temporary exchange token(this depends on application).

With the received access token, securely post it your Mobile backend server (probably HTTPS to avoid man-in-the-middle attack) with that access token you can call the Account Kit API end point to check that the access token is valid as well it provides you mobile number or E-mail As response contains mobile number, you can identify the user and provide the user with the service appropriately. Most important thing is you should pass the access token everytime from the client to the server in order to verify the authenticity of the user. Getting Started :

You should have good knowledge in routeing technique since we are going to concentrate on Express.js, if you're beginner check out thislink to learn more.

Concept :

Since we need to authenticate every request from the app that comes along with access token and others data we could write a middleware to authenticate the every request in the beginning before it executes the API code.

Middleware is nothing but a piece of code which is executed before each and every request entering our express routes. probably we need to write the Account kit verification code here and if it is a success we can make the request to propagate to the corresponding the function else just terminate the live request with authentication errors spitting.

Sample code :

here is sample code to authenticate your mobile backend API end points. we use request module to send a get request to account kit server by providing the accesstoken in url param while if it responds with 200 status code, we are going to extract the mobile number else we are going to consider the request as failed on and informing to the client as error message. before trying this source code, in Facebook Developer dashboard turn off the App-secret required optionand enable client access token flow.

That's it. this is base tutorial on verifying the backend for facebook account kit integrated development.

Author :


Facebook Account Kit Tutorial - Backend Verification using Node.js
SHIVA SURYA

Algorithm Freak, Coder, Web And Android Developer, love to develop Apps for Local Business in my Freetime. For Queries,Quotes Drop me a Mail to [email protected]

本文前端(javascript)相关术语:javascript是什么意思 javascript下载 javascript权威指南 javascript基础教程 javascript 正则表达式 javascript设计模式 javascript高级程序设计 精通javascript javascript教程

主题: FacebookNode.jsAndroidSURY
分页:12
转载请注明
本文标题:Facebook Account Kit Tutorial - Backend Verification using Node.js
本站链接:http://www.codesec.net/view/481582.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 前端(javascript) | 评论(0) | 阅读(27)