0.0.53 • Published 4 months ago

@design-sdk/figma-oauth v0.0.53

Weekly downloads
-
License
-
Repository
github
Last release
4 months ago

Figma-OAuth (@design-sdk/Figma-OAuth)

Figma OAuth, ready to use.

Installation

yarn add @design-sdk/figma-oauth

# or with npm
npm i @design-sdk/figma-oauth

Usage

import { urls, request } from "@design-sdk/figma-oauth";

const oauthTokenRequestUrl = urls.oauth_token_request_url({
  client_id,
  client_secret,
  redirect_uri,
  code,
});

const oauthAuthenticationResult = request.authenticationoauth_token_request_url(
  {
    client_id,
    client_secret,
    redirect_uri,
    code,
  }
);

Configure figma app

  1. using configure method
import { configure } from "@design-sdk/figma-oauth";

configure({
  client_id: "your-figma-app-client-id",
  client_secret: "your-figma-app-client-secret",
});
  1. using .env This package will automatically reference env vars if correcly set.
FIGMA_APP_CLIENT_ID=your-figma-app-client-id
FIGMA_APP_CLIENT_SECRET=your-figma-app-client-secret

Usage with OAuthState for serverside apps

import { OAuth, OAuthState } from "@design-sdk/figma-oauth";

const authProc = OAuth.new();
const url = authProc.authUrl;
// user opens up with this url. this url shall be passed to frontend

// -------------------------------------------------

// on serverside api
// after webapp callback,
const { state, code } = req.body; // e.g.
// the same authproc from above.
const authProc = OAuth.get(state);
authProc.authenticate({ code: code }).then((r) => {
  // do what you have to do with below data.
  r.user_id;
  r.access_token;
  r.refresh_token;
  r.expires_in;

  // this cleans the memory. don't forget to resolve used process to keep things clean.
  OAuth.resolve(state);
  // or..
  authProc.resolve();
});

Refreshing Auth token

import { request } from "@design-sdk/figma-oauth";

const oauthAuthenticationResult = request.tokenrefresh({
  client_id,
  client_secret,
  refresh_token,
});
0.0.52

4 months ago

0.0.53

4 months ago

0.0.48

4 months ago

0.0.42

1 year ago

0.0.43

1 year ago

0.0.40

2 years ago

0.0.41

2 years ago

0.0.39

2 years ago

0.0.37

2 years ago

0.0.38

2 years ago

0.0.36

2 years ago

0.0.20

2 years ago

0.0.21

2 years ago

0.0.22

2 years ago

0.0.23

2 years ago

0.0.24

2 years ago

0.0.25

2 years ago

0.0.15

2 years ago

0.0.16

2 years ago

0.0.17

2 years ago

0.0.18

2 years ago

0.0.19

2 years ago

0.0.30

2 years ago

0.0.31

2 years ago

0.0.32

2 years ago

0.0.10

2 years ago

0.0.33

2 years ago

0.0.11

2 years ago

0.0.34

2 years ago

0.0.12

2 years ago

0.0.35

2 years ago

0.0.13

2 years ago

0.0.14

2 years ago

0.0.26

2 years ago

0.0.9

2 years ago

0.0.27

2 years ago

0.0.8

2 years ago

0.0.28

2 years ago

0.0.29

2 years ago

0.0.7

2 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago

0.0.0

3 years ago