Skip to main content
May 25, 2022
Question

How to create a 1Pass LOGIN ITEM from CLI (op cli) with an attached files/document

  • May 25, 2022
  • 5 replies
  • 232 views

Hello 1Pass!

I'm trying to figure out procedure of creating a 1Pass LOGIN ITEM from CLI (op cli) with a two files attached.

There are some docs in different places and examples like this: https://developer.1password.com/docs/cli/v1/usage

However, at all places I've looked, people EITHER upload a DOCUMENT, or they CREATE AN ITEM. However, I need an ITEM with DOCUMENT included in this item (two documents). From CLI. Ideally, as 1 call. This is due to I don't want to have different records for the same thing. And minimize the time and call amounts. From GUI it's possible...

Additionally, is it possible in the same call to add 2 URLs? So, to sum up:
* 1 login item record, inside of it
* 2 files attached
* 2 URLs attached
* 1 password generated
* 3 tags in the item
* 1 username in the item

Is it possible with CLI and if yes, how? At least the GUI client makes it somehow, so it should be possible in general.

Thanks


1Password Version: 2.3.0
Extension Version: Not Provided
OS Version: Garuda Linux Soaring Talon
Referrer: forum-search:https://1password.community/search?Search=1pass%20cli%20file%20upload

5 replies

May 25, 2022

NB: "Document" or "File" or "Attachment" I don't care, it just have to be 2 files attached to the login item record just same way as it's from the GUI.

May 27, 2022

Can't understand what's the type of attached file (to the "login" record). When I do the following:

op item get "NAME_OF_THE_RECORD_THAT_HAS_FILE_ATTACHED_TO_IT" --fields type=file

The result is returned:
item (...) doesn't have any fields of the following types: "file"

May 30, 2022

Note of research for myself:

"sections": [
{
"name": "add more",
"title": "",
"fields": [
{
"t": "",
"n": "n",
"k": "file",
"v": {
"fileName": "fileName",
"unencryptedSize": unencryptedSize,
"encryptedSize": encryptedSize,
"integrityHash": "integrityHash",
"nonce": "nonce",
"encryptionKey": {
"kty": "oct",
"kid": "kid",
"alg": "A256GCM",
"k": "k",
"ext": true,
"key_ops": [
"encrypt",
"decrypt"
]
},
"documentId": "documentId",
"signingKey": {
"kty": "oct",
"kid": "kid",
"alg": "A256GCM",
"k": "k",
"ext": true,
"key_ops": [
"encrypt",
"decrypt"
]
}
},
"inputTraits": {
"autocorrection": "no",
"autocapitalization": "none"
}
},

Now I need to figure out how to populate all of these fields and send the according to 1Pass...

May 30, 2022


op item get "ITEMID" --format=json

Reveals the JSON where it's possible to see the attached files. Now need to figure out how to send it...

June 1, 2022

Hey @sxiii

We introduced file fields to 1Password browser and desktop apps last year. Admittedly, op has been a bit behind on that front. op is still not able to attach file fields to items that are not of a document type, but it is currently able to retrieve them. This is why you are able to view the document field types in your item outputs.

I do have some good news though. It has recently been prioritized and will likely be included in one of the upcoming releases.