Skip to content

Passport strategy for authenticating with Zalo. An application popular in Viet Nam

License

Notifications You must be signed in to change notification settings

jetthai/passport-zalo

This branch is 46 commits ahead of nguyenthanhxuan/passport-zalo:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

16d646b · Mar 6, 2025

History

60 Commits
Mar 6, 2025
Mar 6, 2025
Mar 6, 2025
Apr 17, 2020
Oct 30, 2020
Mar 6, 2025
Mar 6, 2025

Repository files navigation

passport-zalo

Passport strategy for authenticating with Zalo. An application popular in Viet Nam

Reason to make this

Zalo using OAuth2 method to authenciation but don't know why they are use different url parameter with OAuth2.

OAuth2 using: clientID, clientSecret but Zalo using app_id, app_secret

Install

$ npm i @jetthai/passport-zalo

Usage

Basic conept

Reference document: Zalo Development

List of parameter using on Zalo:

  • app_id: Application ID
  • app_secret: Application Secret
  • redirect_uri: Callback URL

List of URL using on Zalo:

Configure Strategy

passport.use(
  new ZaloStategy(
    {
      appId: ZALO_APP_ID,
      appSecret: ZALO_APP_SECRET,
      callbackURL: "http://localhost:3000/auth/facebook/callback",
      state: "test",
    },
    function (request, accessToken, profile, cb) {
      // Do anything with params above
      return cb(profile);
    }
  )
);

Authenticate Requests

Use passport.authenticate(), specifying the 'zalo' strategy, to authenticate requests.

For example, as route middleware in an Express application:

app.get("/auth/zalo", passport.authenticate("zalo"));

app.get(
  "/auth/zalo/callback",
  passport.authenticate("zalo", { failureRedirect: "/login" }),
  function (req, res) {
    // Successful authentication, redirect home.
    res.redirect("/");
  }
);

License

The MIT License

Copyright (c) 2020 Xuan Nguyen <https://nguyenthanhxuan.name.vn> @Email at xuan12k@gmail.com

About

Passport strategy for authenticating with Zalo. An application popular in Viet Nam

Resources

License

Stars

Watchers

Forks

Languages

  • JavaScript 100.0%