sallazid-auth
v0.0.3
Published
A set of utils to generate auth url, get and refresh tokens
Downloads
1
Readme
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,
});