Code Monkey home page Code Monkey logo

op's Introduction

op

A module that wraps calls to the 1Password op command to retrieve credentials from an active session.

Installation

To install the module, simply run the below or just import it into your code if using modules:

$ go get github.com/walkert/op

Details

The op module expects that you have op installed and have signed-in to an account before (thus generating ~/.op/config). If you already have an OP_SESSION environment variable set, the module will attempt to use that to communicate with op. If it's unset, it will call op and prompt you to sign-in (this will be taken care of by op - not the module) unless you pass an explicit password to New.

If an account is not specified, the module will attempt to use the only account in the config file. If there is more than one, you'll need to specify its name explicitly.

Getting Started

Get the username and password from a specific 1password account

package main

import (
    "fmt"
    "log"

    "github.com/walkert/op"
)

func main() {
    o, err := op.New(op.WithAccount("myaccount"))
    if err != nil {
        log.Fatal(err)
    }
    user, pass, err := o.GetUserPass("item name")
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println("Got user and pass:", user, pass)
}

Get the totp for an item from the default account

package main

import (
    "fmt"
    "log"

    "github.com/walkert/op"
)

func main() {
    totp, err := op.GetTotp("my item")
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println("Got totp:", totp)
}

op's People

Contributors

walkert avatar

Stargazers

 avatar

Watchers

James Cloos avatar

Forkers

sjwl

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.