All Projects → gimdongwoo → parse-oauth2-sns

gimdongwoo / parse-oauth2-sns

Licence: Apache-2.0 license
Parse-server module for implementing an OAuth2 Social Media Login with Express in Node.js

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to parse-oauth2-sns

Brighter
Command Dispatcher, Processor, and Distributed Task Queue
Stars: ✭ 1,393 (+6533.33%)
Mutual labels:  sns
Enqueue Dev
Message Queue, Job Queue, Broadcasting, WebSockets packages for PHP, Symfony, Laravel, Magento. DEVELOPMENT REPOSITORY - provided by Forma-Pro
Stars: ✭ 1,977 (+9314.29%)
Mutual labels:  sns
undertow-pac4j
Security library for Undertow: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 35 (+66.67%)
Mutual labels:  social-login
Sms
Laravel SMS Gateway Integration Package
Stars: ✭ 112 (+433.33%)
Mutual labels:  sns
Oss.clients.sns
社交网站sdk(标准库),微信公众号(订阅号,服务号,小程序)接口sdk-包含消息回复(明文和安全模式),Oauth2.0授权等
Stars: ✭ 136 (+547.62%)
Mutual labels:  sns
Plus
💝The Plus (ThinkSNS+) is a powerful, easy-to-develop social system built with Laravel.
Stars: ✭ 2,148 (+10128.57%)
Mutual labels:  sns
Plus Small Screen Client
本库已经合并进入 https://github.com/slimkit/plus 中,仅提供 2.1 及以前版本下载使用!
Stars: ✭ 83 (+295.24%)
Mutual labels:  sns
Naver-AI-Hackathon-Speech
2019 Clova AI Hackathon : Speech - Rank 12 / Team Kai.Lib
Stars: ✭ 26 (+23.81%)
Mutual labels:  naver
Aws Sdk Perl
A community AWS SDK for Perl Programmers
Stars: ✭ 153 (+628.57%)
Mutual labels:  sns
amazon-sns-java-extended-client-lib
This AWS SNS client library allows to publish messages to SNS that exceed the 256 KB message size limit.
Stars: ✭ 23 (+9.52%)
Mutual labels:  sns
Awesome Sns
A curated list of useful SNS topics
Stars: ✭ 118 (+461.9%)
Mutual labels:  sns
Components Contrib
Community driven, reusable components for distributed apps
Stars: ✭ 131 (+523.81%)
Mutual labels:  sns
Symphony
🎶 一款用 Java 实现的现代化社区(论坛/BBS/社交网络/博客)平台。
Stars: ✭ 13,080 (+62185.71%)
Mutual labels:  sns
Loafer
Asynchronous message dispatcher - Currently using asyncio and amazon SQS
Stars: ✭ 104 (+395.24%)
Mutual labels:  sns
aws-developer-associate-certificate
Note to pass the AWS Developer Associate Exam
Stars: ✭ 53 (+152.38%)
Mutual labels:  sns
Aws Cli Cheatsheet
☁️ AWS CLI + JQ = Make life easier
Stars: ✭ 94 (+347.62%)
Mutual labels:  sns
Justsaying
A light-weight message bus on top of AWS services (SNS and SQS).
Stars: ✭ 157 (+647.62%)
Mutual labels:  sns
aws-pdf-textract-pipeline
🔍 Data pipeline for crawling PDFs from the Web and transforming their contents into structured data using AWS textract. Built with AWS CDK + TypeScript
Stars: ✭ 141 (+571.43%)
Mutual labels:  sns
BringMyOwnBeer-
PunkAPI(BrewDog) 을 이용한 RxSwift-MVVM 예제 (Naver Tech Concert)
Stars: ✭ 80 (+280.95%)
Mutual labels:  naver
Collipa
The source code of Collipa
Stars: ✭ 217 (+933.33%)
Mutual labels:  sns

Parse OAuth2 SNS (Social Media)

npm version

Node.JS & Express module for social media (Facebook, Google, Instagram) auth and login to parse-server. Plus, Korean SNS (Social Media) supports (Naver, Daum, Kakao)

Install

npm install --save parse-oauth2-sns

np How to Use


For Application

  1. Use internal browser (like Android Webview)

  2. Open auth url : /facebook/auth

http://__your_host__/oauth2/facebook/auth
  1. Check url changed to '/callback'

  2. Then url chenged to '/callback', get authdata from body.

// URL : facebook/callback
{"access_token":"...","expiration_date":"..."}

For Web

  1. Open auth url with URL in callback parameter : /facebook/auth?callback=URL
window.location.href =
  "http://__your_host__/oauth2/facebook/auth?callback=" +
  encodeURIComponent("/loginCallback?type=facebook");
Params Type Description
callback string callback url. Redirected after authentication
host string If using proxy, can change api url host. ex) host=your_host/api
  1. Then URL is called, get authdata from querystring.
http://__host__/loginCallback?type=facebook&access_token=...& expiration_date=...

Routes

Facebook Routes

  • /facebook/auth

    • request [get] : callback (url, option), host (url, option)

    • response : redirect to Facebook OAuth page

  • /facebook/callback

    • request : from facebook OAuth page

    • response : json

    {"access_token":"...","expiration_date":"..."}
  • /facebook/login

    • request [post] : json (facebook auth info)
    {"access_token":"...","expiration_date":"..."}
    • response : parse-serve user object (username equal to facebook email)
    {"objectId": "ziJdB2jBul", "username": "__facebook.email__", authData, ...}

Google Routes

  • /google/auth

    • request [get] : callback (url, option), host (url, option)

    • response : redirect to Google OAuth page

  • /google/callback

    • request : from google OAuth page

    • response : json

    {"access_token":"...","expiration_date":"..."}
  • /google/login

    • request [post] : json (google auth info)
    {"access_token":"...","expiration_date":"..."}
    • response : parse-serve user object (username equal to google email)
    {"objectId": "ziJdB2jBul", "username": "__google.email__", authData, ...}

Instagram Routes

  • /instagram/auth

    • request [get] : callback (url, option), host (url, option)

    • response : redirect to Instagram OAuth page

  • /instagram/callback

    • request : from instagram OAuth page

    • response : json

    {"access_token":"...","user":"..."}
  • /instagram/login

    • request [post] : json (instagram auth info)
    {"access_token":"..."}
    • response : parse-server user object (username equal to instagram username)
    {"objectId": "ziJdB2jBul", "username": "__instagram.username__", authData, ...}
  • /instagram/link : parse-server user link to instagram user.

    • request [post] : instagram token and parse-server user info.
    {"access_token":"", "username": "__parse-server user.username__"}
    • response : parse-server user object linked instagram
    {"objectId": "ziJdB2jBul", "username": "__username__", authData, ...}
  • /instagram/recent : get recent post from instagram

    • request [get] : userId (parse-server user.objectId)

    • response : instagram posts

    [{images, caption, comments, ...}, ...]

Naver Routes

  • /naver/auth

    • request [get] : callback (url, option), host (url, option)

    • response : redirect to naver OAuth page

  • /naver/callback

    • request : from naver OAuth page

    • response : json

    {"access_token":"...","expiration_date":"..."}
  • /naver/login

    • request [post] : json (naver auth info)
    {"access_token":"...","expiration_date":"..."}
    • response : parse-serve user object (username equal to naver email)
    {"objectId": "ziJdB2jBul", "username": "__naver.email__", authData, ...}

Daum Routes

  • /daum/auth

    • request [get] : callback (url, option), host (url, option)

    • response : redirect to daum OAuth page

  • /daum/callback

    • request : from daum OAuth page

    • response : json

    {"access_token":"...","expiration_date":"..."}
  • /daum/login

    • request [post] : json (daum auth info)
    {"access_token":"...","expiration_date":"..."}
    • response : parse-server user object (username equal to daum userid, not email provided)
    {"objectId": "ziJdB2jBul", "username": "__daum.userid__", authData, ...}

Kako Routes

  • /kakao/auth

    • request [get] : callback (url, option), host (url, option)

    • response : redirect to kakao OAuth page

  • /kakao/callback

    • request : from kakao OAuth page

    • response : json

    {"access_token":"...","expiration_date":"..."}
  • /kakao/login

    • request [post] : json (kakao auth info)
    {"access_token":"...","expiration_date":"..."}
    • response : parse-server user object (username equal to kakao email or kakao userid)
    {"objectId": "ziJdB2jBul", "username": "__kakao.(kaccount_email||id)__", authData, ...}

Initialize

Setup up process.env

  • It's work with parse-rest-nodejs.

    // Recommend to use 'better-npm-run'.
    process.env.SERVER_URL = "http://__host__:__port__/parse";
    process.env.APP_ID = "__app_id__";
    process.env.MASTER_KEY = "__master_key__";
    process.env.FB_APPIDS = "__fb_key__";
    process.env.FB_SECRETS = "__fb_secret__";
    process.env.GOOGLE_APPIDS = "__google_key__";
    process.env.GOOGLE_SECRETS = "__goole_secret__";
    process.env.INSTA_APPIDS = "__insta_key__";
    process.env.INSTA_SECRETS = "__insta_secret__";
    process.env.NAVER_APPIDS = "__naver_key__";
    process.env.NAVER_SECRETS = "__naver_secret__";
    process.env.DAUM_APPIDS = "__daum_key__";
    process.env.DAUM_SECRETS = "__daum_secret__";
    process.env.KAKAO_RESTKEY = "__kakao_restkey__";
    process.env.KAKAO_SECRETS = "__kakao_secret__";

Router using Express

  • load module

    // es6
    import express from "express";
    import session from "express-session";
    import SocialOAuth2 from "parse-oauth2-sns";
    import bodyParser from "body-parser";
    // es5
    var express = require("express");
    var session = require("session");
    var SocialOAuth2 = require("parse-oauth2-sns").default;
    var bodyParser = require("body-parser");
  • create object

    // for use req.session
    app.use(
      session({
        secret: "___secret_key_for_session___",
        resave: false,
        saveUninitialized: false
        // cookie: { maxAge: 60000 }
      })
    );
    // for use req.body
    app.use(bodyParser.json());
    
    // OAuth2
    app.use("/oauth2", SocialOAuth2.create({ path: "/oauth2" }));
    // OR OAuth2 + userObject Handler
    // Handler is normal function or promise function.
    app.use('/oauth2', SocialOAuth2.create({ path: '/oauth2', userHandler: function(req, user) { ...  return user; } }));
  • Full code is in test.js

Addon Features

User

  • user block/ban

    • if user.isBanned value is setted, user can't login.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].