sallazid-auth
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

Salla Zid Auth utils

A set of utils to generate auth url, get and refresh tokens

Usage:

Generate Auth Url

import { GenerateAuthUrl } from "sallazid-auth";

const authUrl = GenerateAuthUrl(
    'salla', // Or 'zid' {
    state: 'random_string',
    response_type: "code",
    client_id: process.env.SALLA_CLIENT_ID,
    redirect_uri: process.env.SALLA_REDIRECT_URI
})

Get Token

retrieve an access token from salla

import { getSallaStoreToken } from "./token";

const data = await getSallaStoreToken({
  scope: "offline_access",
  grant_type: "authorization_code",
  code: "code",
  client_secret: process.env.SALLA_CLIENT_SECRET,
  client_id: process.env.SALLA_CLIENT_ID,
  redirect_uri: process.env.SALLA_REDIRECT_URI,
});

Refresh Token

import { refreshToken } from "./token";

refreshToken("salla", {
  grant_type: "refresh_token",
  refresh_token: "refresh_token",
  client_secret: process.env.SALLA_CLIENT_SECRET,
  client_id: process.env.SALLA_CLIENT_ID,
  redirect_uri: process.env.SALLA_REDIRECT_URI,
});

Readme

Keywords

none

Package Sidebar

Install

npm i sallazid-auth

Weekly Downloads

0

Version

0.0.3

License

MIT

Unpacked Size

14 kB

Total Files

14

Last publish

Collaborators

  • benali1