0.0.7 • Published 2 months ago
@swit-api/oauth v0.0.7
Swit Api Oauth
- Provides a method for helpers for oauth authentication.
Requirements
- Nodejs v18 or higher
Install
npm install @swit-api/oauth
Basic Usage
Create Oauth
Create an instance by putting options in the Oauth class constructor.
import { Oauth } from '@swit-api/oauth';
const clientId = process.env.CLIENT_ID as string;
const clientSecret = process.env.CLIENT_SECRET as string;
const redirectUri = process.env.REDIRECT_URI as string;
const scope = [
'channel:read',
'message:read',
'channel:write',
'idea:read',
'idea:write',
'message:write'
];
const oauth = new Oauth({
clientId,
clientSecret,
redirectUri,
state: '',
scope
});
Get url to authorize oauth
Get oauth authentication page url via getAuthorizeUrl method.
oauth.getAuthorizeUrl()
Get url to authorize oauth
After authentication, you receive the code parameter that is passed to the redirect url and pass it to the function below to get a token.
const code = 'Code passed after authentication';
oauth.getTokenByAuthorizationCode(code);
Update token with refresh token
Get a renewed token with a previously received refresh token.
const refreshToken = 'refresh token';
oauth.getTokenByRefreshToken(refreshToken);
0.0.7
2 months ago
0.0.6
2 months ago
0.0.5
3 months ago
0.0.4
3 months ago
0.0.3
3 months ago
0.0.2
4 months ago
0.0.1
6 months ago
0.0.1-alpha.20
6 months ago
0.0.1-alpha.14
7 months ago
0.0.1-alpha.12
7 months ago
0.0.1-alpha.0
7 months ago