OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

API Login with Bitwarden command bw login --apikey

  • Thread starter Thread starter Nedim Asani
  • Start date Start date
N

Nedim Asani

Guest
I'm working on a Node.js script to log in to a Bitwarden vault using the command bw login --apikey. However, after running this command, a prompt appears asking for the client_id. After providing the client_id, another prompt appears for the client_secret. I'm having trouble passing these values automatically to the prompts. Does anyone have any idea how to achieve this?


Code:
const input = `test  test1`;
      // Spawn a child process to handle the interactive login process
      const child = spawnSync('bw', ['login', '--apikey'], {
        input: input,
        stdio: ['pipe', 'pipe', 'pipe']
      });

      if (child.error) {
        throw child.error;
      }

      if (child.stderr && child.stderr.toString()) {
        console.error(`stderr: ${child.stderr.toString()}`);
      }

      if (child.stdout && child.stdout.toString()) {
        console.log(`stdout: ${child.stdout.toString()}`);
      }

      if (child.status !== 0) {
        console.log(`Bitwarden login process exited with code ${child.status}`);
        throw new Error('Failed to log into Bitwarden');
      }
    }

result im getting as u can see in the picture it adds both values to the first prompt!

<p>I'm working on a Node.js script to log in to a Bitwarden vault using the command bw login --apikey. However, after running this command, a prompt appears asking for the client_id. After providing the client_id, another prompt appears for the client_secret. I'm having trouble passing these values automatically to the prompts. Does anyone have any idea how to achieve this?</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>const input = `test test1`;
// Spawn a child process to handle the interactive login process
const child = spawnSync('bw', ['login', '--apikey'], {
input: input,
stdio: ['pipe', 'pipe', 'pipe']
});

if (child.error) {
throw child.error;
}

if (child.stderr && child.stderr.toString()) {
console.error(`stderr: ${child.stderr.toString()}`);
}

if (child.stdout && child.stdout.toString()) {
console.log(`stdout: ${child.stdout.toString()}`);
}

if (child.status !== 0) {
console.log(`Bitwarden login process exited with code ${child.status}`);
throw new Error('Failed to log into Bitwarden');
}
}</code></pre>
</div>
</div>
</p>
<p><a href="https://i.sstatic.net/ykzS8Hv0.png" rel="nofollow noreferrer">result im getting</a>
as u can see in the picture it adds both values to the first prompt!</p>
 

Latest posts

Top