🔑 Prompt a YubiKey device to generate an OATH code
You can fetch this library by running the following
go get -u github.com/joshdk/ykmango
Additionally, this library has a runtime dependency on ykman
which must be installed before use.
import (
"fmt"
"github.com/joshdk/ykmango"
)
// List the currently configured OATH slot names.
names, err := ykman.List()
if err != nil {
panic(err.Error())
}
for _, name := range names {
fmt.Printf("Found code named: %s\n", name)
// Found code named: aws-mfa
}
// Generate an OATH code using the given slot name.
// You may need to touch your YubiKey device if the
// slot is configured to require touch.
code, err := ykman.Generate("aws-mfa")
if err != nil {
panic(err.Error())
}
fmt.Printf("Your code is: %s\n", code)
// Your code is: 150509
This library is distributed under the MIT License, see LICENSE.txt for more information.