Creating new login item including website URL

zcutlip
zcutlip
Community Member

I'm trying to create login items with op create item "Login", but I don't see a way to populate the website at time of creation. As far as I can tell, the following are true:

  • The base64 encoded JSON that you feed to op create item is really just the details dictionary from an item object
  • The website(s) for a login item exist outside the details dictionary (I think in the overview dictionary?)

I don't see a way to encode one or more website URLs into the JSON for item creation.

Am I missing something?

Thanks,
Zach


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

Comments

  • ag_yaron
    ag_yaron
    1Password Alumni

    Hey @zcutlip ,

    Indeed, the URL is found in the "overview" section of the item. Here's an example:

    {
      "details": {
        "fields": [
          {
            "designation": "username",
            "name": "username",
            "type": "T",
            "value": "testuser"
          },
          {
            "designation": "password",
            "name": "password",
            "type": "P",
            "value": "testpassword"
          }
        ],
        "notesPlain": "",
        "passwordHistory": [],
        "sections": [
          {
            "name": "linked items",
            "title": "Related Items"
          }
        ]
      },
      "overview": {
        "URLs": [
          {
            "l": "",
            "u": "https://amazon.com"
          }
        ],
        "ainfo": "testuser",
        "ps": 10,
        "title": "Amazon",
        "url": "https://amazon.com"
      }
    }
    

    Can you please share your list of commands here and what their output is so we can check where things go wrong?

  • zcutlip
    zcutlip
    Community Member

    If I take the JSON just as posted it, encode it, and use it to create a new login item, you don't get a valid login:

    op create item Login "$(op encode < ag_yarons_example.json)" --title "ag yaron's example" --vault "Test Data"
    

    Here's a screenshot of the resulting entry in the 1Password UI:

    Since the template for login items just wants the details dictionary itself, I can pull just that part out of your example:

    {
        "fields": [
            {
                "designation": "username",
                "name": "username",
                "type": "T",
                "value": "testuser"
            },
            {
                "designation": "password",
                "name": "password",
                "type": "P",
                "value": "testpassword"
            }
        ],
        "notesPlain": "",
        "passwordHistory": [],
        "sections": [
            {
                "name": "linked items",
                "title": "Related Items"
            }
        ]
    }
    

    When I try again, it works:

    op create item Login "$(op encode < just_details_dict.json)" --title "just details dict" --vault "Test Data"
    

    Screenshot:

    Of course, leaving out the overview dictionary means this new login item has no associated website. I don't see a way to include the associated website when I encode and create the login.

    Zach

  • ag_yaron
    ag_yaron
    1Password Alumni

    Thanks for the followup and additional clarification @zcutlip .

    I've investigated this and it seems currently the only way to add a URL when importing an encoded JSON is to use the --url flag when importing the file, but this command only supports one URL and not multiple.

    I've forwarded this to the development team so that they may improve and enhance the import function to support adding multiple URLs and the entire "overview" section.

    Thanks for bringing this up!

  • zcutlip
    zcutlip
    Community Member

    No, thank you. The --url should get me going for now. It slipped my notice before.

    Hopefully in the future it'll be possible to create a fully formed login item in JSON, but this works for now.

    Cheers!
    Zach

  • ag_yaron
    ag_yaron
    1Password Alumni

    I'm glad to hear that will suffice for now, @zcutlip !

    Cheers :chuffed:

This discussion has been closed.