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

sxiiisxiii
Community Member
in CLI

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:1pass cli file upload

Comments

  • sxiiisxiii
    Community Member

    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.

  • sxiiisxiii
    Community Member

    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"

  • sxiiisxiii
    Community Member
    edited May 30

    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...

  • sxiiisxiii
    Community Member
    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...

  • Justin.Yoon_1PJustin.Yoon_1P

    Team Member

    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.

Leave a Comment

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