@gat-solutions/google-auth
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

E-commerce Integration

Introduction

Đây là một thư viện hỗ trợ gọi API Google Auth. Thư viện bao gồm 1 service gọi API đi kèm những định nghĩa type dành cho typescript.

Installation

$ npm install @gat-solutions/google-auth

Config environment

CLIENT_EMAIL=
PRIVATE_KEY=
PROJECT_ID=

EcommerceService

Muốn kết nối được với service Google Auth bạn cần có 3 key ở trên. Sau đó dùng hàm dưới đây để lấy access token.

...
    import { configs } from "../configs";
    const googleAuthHelper = new GoogleAuthHelper({
        clientEmail: "CLIENT_EMAIL",
        privateKey: "PRIVATE_KEY",
        projectId: "PROJECT_ID",
    });
...
...
    const { token } = await googleAuthHelper.getTokenResponse();
...

getConfig

Lấy cấu hình

...
    import { ConfigGoogleAuth } from "@gat-solutions/google-auth";


    const { token } = await googleAuthHelper.getTokenResponse();
    const config : ConfigGoogleAuth = await googleAuthHelper.getConfig(token)
...

insertConfigAuthorizedDomains

Thêm tên miền vào AuthorizedDomains của cấu hình

...
    import { ConfigGoogleAuth } from "@gat-solutions/google-auth";


    const { token } = await googleAuthHelper.getTokenResponse();

    const newDomain = "example.com"
    const config : ConfigGoogleAuth = await googleAuthHelper.insertConfigAuthorizedDomains(newDomain, token);
...

removeConfigAuthorizedDomains

Xóa tên miền ra khỏi AuthorizedDomains của cấu hình

...
   import { ConfigGoogleAuth } from "@gat-solutions/google-auth";


    const { token } = await googleAuthHelper.getTokenResponse();

    const domainRemove = "example.com"
    const config : ConfigGoogleAuth = await googleAuthHelper.removeConfigAuthorizedDomains(newDomain, token);
...

Readme

Keywords

Package Sidebar

Install

npm i @gat-solutions/google-auth

Weekly Downloads

32

Version

1.0.6

License

ISC

Unpacked Size

10.7 kB

Total Files

8

Last publish

Collaborators

  • huygiale
  • dotranminhchu
  • duyanhit
  • thaivlinh