Illegal Base64 data at input byte 2 in example of how to create new items

Options
jordan_cbw
jordan_cbw
Community Member

I was creating a script for work to generate randomize passwords that saves in 1password then prints out as a file for my server.

I was following the example of just making a test one:
Found near the bottom of https://support.1password.com/command-line-getting-started/

D=$(op get template login | jq -c '.fields[1].value = "my secret"' | op encode)
op create item login "My New Item" $D

When I run that command (after singing in successfully), I get "(ERROR) illegal base64 data at input byte 2"

I also would appreciate any information about setting up a Secure Note template. I wanted to set up a secure note with two sections. The first section has 2 password fields with the second section having 3 password fields. All 5 fields should be randomized passwords. I then need to store those 5 passwords as variables to then print to a file.

Thanks in advance!


1Password Version: 6.8.3
Extension Version: Not Provided
OS Version: 10.13
Sync Type: icloud

Comments

  • cohix
    cohix
    1Password Alumni
    Options

    Hey @jordan_cbw!

    I've got some good news and some bad news. Good news is that you can fix that issue by changing your second line to:
    op create item login $D --title="My New Item"

    The bad news is that we dropped the ball and didn't look closely enough at our documentation when we updated that command. I'll make sure that gets fixed up ASAP.

    As for the secure note, I'll do my best here:

    {
        "fields": [],
        "notesPlain": "",
        "sections": [
          {
            "fields": [
              {
                "k": "concealed",
                "n": "mvd3eyoc6emv46ijcnabkbbh3u",
                "t": "pass1",
                "v": "asdf"
              },
              {
                "k": "concealed",
                "n": "caz2tzaui6fbfdxx7idpmsm6gu",
                "t": "pass2",
                "v": "asdf"
              }
            ],
            "name": "Section_bkdkgwlxwzpvrxww6c4wfpf2ce",
            "title": "TwoPasswords"
          },
          {
            "fields": [
              {
                "k": "concealed",
                "n": "maa7wkf3gdpmq3bdumwa7mhnie",
                "t": "pass1",
                "v": "asdf"
              },
              {
                "k": "concealed",
                "n": "y77lqnuodx3572gth73ls5m3wq",
                "t": "pass2",
                "v": "asdf"
              },
              {
                "k": "concealed",
                "n": "ru6f4wufva7wlzb764m6rnj5ty",
                "t": "pass3",
                "v": "asdf"
              }
            ],
            "name": "Section_dpwbe7a4zfbwixdoiczs52rxhi",
            "title": "ThreePasswords"
          }
        ]
      }
    

    For each section, the name should be "Section_[random string]", and for each field the "n" should be a random string. The "t" fields are the titles you see in the app, and "v" is the actual value of the field. We don't currently have the secure password generator in the CLI, so unfortunately you'll have to generate the passwords some other way for now.

    Give that a try and let me know how it goes!

  • jordan_cbw
    jordan_cbw
    Community Member
    Options

    Thanks so much for this reply! It's very helpful. I found a bash command to do a random generation of a password, so I think I'm good to go.

    cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1

  • Hah. That's awesome.

    One day I'd love for us to have a strong password generator in the CLI.

    Rick

This discussion has been closed.