Skip to main content
zcutlip
Jul 23, 2021 2:10 AM UTC
Question

Creating new login item including website URL

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

5 replies

Jul 25, 2021 7:50 AM UTC

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
zcutlipAuthor
Jul 25, 2021 11:10 PM UTC

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:

console
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:

JSON
{
"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:

Console
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

Jul 27, 2021 6:55 AM UTC

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
zcutlipAuthor
Jul 27, 2021 3:18 PM UTC

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

Jul 28, 2021 6:32 AM UTC

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

Cheers :chuffed: