zmp-developer-token

3.1.0 • Public • Published

Zalo Mini App Developer Token

If you're tired of copying the access token every 1 hour, this library is for you

Setup

npm install -D zmp-developer-token

Usage

import { getDeveloperAccessToken } from "zmp-developer-token";
import api from "zmp-sdk";

async function getAccessToken() {
  await api.login();
  let token = await api.getAccessToken();
  if (token === "DEFAULT ACCESS TOKEN") {
    token = await getDeveloperAccessToken();
  }
  return token;
}

If you have multiple mini apps inside one domain, specify a unique namespace:

await getDeveloperAccessToken("my-app");

How does it work?

You need to provide a valid App ID (which provides the access token), App Secret (to get new tokens) and an initial Refresh Token (which will last many months, and keep renewed automatically until you lost it).

localStorage.setItem("zdt.appId", "");
localStorage.setItem("zdt.appSecret", "");
localStorage.setItem("zdt.refreshToken", "");

Only execute the above scripts inside Devtools > Console. Do not put it inside of your source code ☠️

License

Copyright (c) Zalo Group. and its affiliates. All rights reserved.

The examples provided by Zalo Group are for non-commercial testing and evaluation purposes only. Zalo Group reserves all rights not expressly granted.

Readme

Keywords

none

Package Sidebar

Install

npm i zmp-developer-token

Weekly Downloads

1,088

Version

3.1.0

License

none

Unpacked Size

18.7 kB

Total Files

6

Last publish

Collaborators

  • nguyenhongphat0