Advise on Creating Custom fields using login templates

Can I get some advise on creating custom fields using the Json login template please?

I am using this and the UserName and Password fields are updated but not the notes or Tags or Customer name

As well as create vaults with Custom fields I would like to know how i can update a login item once it has been created?

Also can you create a login item using a template and generate a password ?

$userName = "[email protected]"
$AAdminPss = Get-RandomAlphanumericString -length 30

###### Create Logins

$AzureAdmin = "{
"notesPlain": "$notes",
"tag": "Test Tag",
"sections": [],
"passwordHistory": [],
"fields": [
{
"value": "$userName",
"name": "username",
"type": "T",
"designation": "username"
},
{
"value": "$AAdminPss",
"name": "password",
"type": "P",
"designation": "password"
},
{
"value": "CustomerName",
"name": "customer",
"type": "T",
"designation": "CustomerName"
}
]
}" | op encode
op create item Login $AzureAdmin --title "Azure Admin" --vault $1PVaultName


1Password Version: Not Provided
Extension Version: Not Provided
OS Version: Not Provided
Sync Type: Not Provided

Comments

  • ag_yaronag_yaron

    Team Member

    Hey @PeterCharleston ,

    To add custom fields to a new item, you can use this example:

    {
      "fields": [
        {
          "designation": "username",
          "name": "username",
          "type": "T",
          "value": "$username"
        },
        {
          "designation": "password",
          "name": "password",
          "type": "P",
          "value": "$password"
        }
      ],
      "notesPlain": "$notes",
      "passwordHistory": [],
      "sections": []
    }
            {
              "k": "string",
              "n": "api_key",
              "t": "API Key",
              "v": "ori"
            },
            {
              "k": "string",
              "n": "app_id",
              "t": "App ID",
              "v": "newApp"
            },
            {
              "k": "string",
              "n": "double_hash",
              "t": "Double Hash",
              "v": "test"
            },
            {
              "k": "string",
              "n": "webhook",
              "t": "Webhook",
              "v": "webhook"
            },
            {
              "k": "concealed",
              "n": "secret_key",
              "t": "Secret Key",
              "v": "secret"
            }
          ],
          "name": "connection_info",
          "title": "Connection Info"
        }
      ]
    }
    

    To generate a password, add the --generate-password flag, with any additional requirements for the password as shown here: https://support.1password.com/command-line-reference/#options-for-create-item

    To add tags, use the --tags flag and list tags separated by commas.

    I hope this will point you in the right direction.

  • Hi Ag_yaron

    thanks for your response.

    Can you advise on the two square bracket closes i have highlighted in the screen shot please?

    Should the custom fields be included in a square brackets header?

  • ag_yaronag_yaron

    Team Member

    Hey @PeterCharleston ,

    Yes, I missed it there. Sorry about that. You'll want them to be included in the squared bracket.

  • Hi ag_yaron,

    sorry but which bracket header should they be included in?
    I tried :

    `"sections`": [
                {
          `"k`": `"string`",
          `"n`": `"api_key`",
          `"t`": `"API Key`",
          `"v`": `"ori`"
        }    
    ]
    

    but this did not work

  • ag_yaronag_yaron

    Team Member

    Hey @PeterCharleston ,

    Sorry for the confusion here. I've edited the structure below.
    The fields at the top refer to the main fields of the item (username, password). Then, the fields under the section brackets are custom fields:

    {
      "fields": [
        {
          "designation": "username",
          "name": "username",
          "type": "T",
          "value": "$username"
        },
        {
          "designation": "password",
          "name": "password",
          "type": "P",
          "value": "$password"
        }
      ],
      "notesPlain": "$notes",
      "passwordHistory": [],
      "sections": [
            {
          "fields": [
            {
              "k": "string",
              "n": "api_key",
              "t": "API Key",
              "v": "ori"
            },
            {
              "k": "string",
              "n": "app_id",
              "t": "App ID",
              "v": "NewApp"
            },
            {
              "k": "string",
              "n": "double_hash",
              "t": "Double Hash",
              "v": "test"
            },
            {
              "k": "string",
              "n": "webhook",
              "t": "Webhook",
              "v": "webhook"
            },
            {
              "k": "concealed",
              "n": "secret_key",
              "t": "Secret Key",
              "v": "secret"
            }
          ],
          "name": "connection_info",
          "title": "Connection Info"
        }
      ]
    }
    
  • ok that works great!
    Thanks for that.

    How can I update/edit an individual field value once the login item is created?
    How can i add an additional custom field to an existing Login item?

  • ag_yaronag_yaron

    Team Member

    Glad to hear it :)

    Only main fields can be edited in existing items (e.g. only the main username/password field). Custom fields cannot be edited (yet). You'll have to re-create the item if you want to edit/add a custom field and then delete the original one.

  • ok cool

    thanks, you really helped me out

  • ag_yaronag_yaron

    Team Member

    You're most welcome! :)

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file