yarn add @daisycon/oauth-cli-client
npm install @daisycon/oauth-cli-client
To start the oAuth request in your initial starting page add the following snippit
import {OauthService, PkceService} from '@daisycon/oauth-cli-client';
const oAuthService: OauthService = new OauthService(new PkceService());
oAuthService.startAuthorizationRequest(YOUR_CLIENT_ID, YOUR_AUTHORIZED_REDIRECT_URI);
Then on the authorized redirect URI add the following snippet. Then store the returned tokens somewhere safe.
import {AccessTokenResponseInterface, OauthService, PkceService} from '@daisycon/oauth-cli-client';
const oAuthService: OauthService = new OauthService(new PkceService());
const accessTokens: AccessTokenResponseInterface = oAuthService.startAccessTokenExchange(YOUR_CLIENT_ID, YOUR_AUTHORIZED_REDIRECT_URI);
console.log(accessTokens);
After installation, you can run the client as follows
npx daisycon-oauth-cli --clientId=CLIENT_ID --clientSecret=CLIENT_SECRET --outputFile="./tokens.json"