diff --git a/src/shared/login.js b/src/shared/login.js new file mode 100644 index 0000000..688b9d0 --- /dev/null +++ b/src/shared/login.js @@ -0,0 +1,19 @@ +import { AuthService, OpenAPI } from "@odit/lfk-client-node"; +import * as dotenv from 'dotenv'; +dotenv.config() + +export async function login() { + OpenAPI.BASE = process.env.BASE_URL; + const user = process.env.USER; + const password = process.env.PASSWORD; + + if (!user || !password || !OpenAPI.BASE) { + process.exit(1) + } + + const auth = await AuthService.authControllerLogin({ username: user, password }); + OpenAPI.TOKEN = auth.access_token; + + console.log("Logged in"); + return auth; +} \ No newline at end of file