UNPKG

@redocly/cli

Version:

[@Redocly](https://redocly.com) CLI is your all-in-one API documentation utility. It builds, manages, improves, and quality-checks your API descriptions, all of which comes in handy for various phases of the API Lifecycle. Create your own rulesets to make

34 lines 1.32 kB
import { logger } from '@redocly/openapi-core'; import { exitWithError } from '../utils/error.js'; import { RedoclyOAuthClient } from '../auth/oauth-client.js'; import { getReuniteUrl } from '../reunite/api/index.js'; export async function handleLogin({ argv, config }) { const reuniteUrl = getReuniteUrl(config, argv.residency); try { const oauthClient = new RedoclyOAuthClient(); if (argv.verbose) { logger.info(`OAuth client initialized.\n`); logger.info(`Local credentials file path: ${oauthClient.credentialsFilePath}\n`); } await oauthClient.login(reuniteUrl); } catch (error) { if (argv.verbose) { logger.error(`Residency: ${argv.residency}.\n`); logger.error(`Login URL: ${reuniteUrl}.\n`); logger.error(error.stack || error.message); } if (argv.residency) { exitWithError(`❌ Connection to ${reuniteUrl} failed.`); } else { exitWithError(`❌ Login failed. Please check your credentials and try again.`); } } } export async function handleLogout() { const oauthClient = new RedoclyOAuthClient(); oauthClient.logout(); logger.output('Logged out from the Redocly account. ✋ \n'); } //# sourceMappingURL=auth.js.map