0.0.53 • Published 2 years ago
@design-sdk/figma-oauth v0.0.53
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
- 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",
});
- 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
2 years ago
0.0.53
2 years ago
0.0.48
2 years ago
0.0.42
3 years ago
0.0.43
3 years ago
0.0.40
3 years ago
0.0.41
3 years ago
0.0.39
3 years ago
0.0.37
3 years ago
0.0.38
3 years ago
0.0.36
3 years ago
0.0.20
3 years ago
0.0.21
3 years ago
0.0.22
3 years ago
0.0.23
3 years ago
0.0.24
3 years ago
0.0.25
3 years ago
0.0.15
3 years ago
0.0.16
3 years ago
0.0.17
3 years ago
0.0.18
3 years ago
0.0.19
3 years ago
0.0.30
3 years ago
0.0.31
3 years ago
0.0.32
3 years ago
0.0.10
3 years ago
0.0.33
3 years ago
0.0.11
3 years ago
0.0.34
3 years ago
0.0.12
3 years ago
0.0.35
3 years ago
0.0.13
3 years ago
0.0.14
3 years ago
0.0.26
3 years ago
0.0.9
3 years ago
0.0.27
3 years ago
0.0.8
3 years ago
0.0.28
3 years ago
0.0.29
3 years ago
0.0.7
3 years ago
0.0.3
4 years ago
0.0.2
4 years ago
0.0.1
4 years ago
0.0.0
4 years ago