GitHub Authentication.
go get github.com/pocke/gha
import "github.com/pocke/gha"
func main() {
key, err := gha.Auth("pocke", "PASSWORD", gha.Request{
Note: "gist-app",
Scopes: []string{"gist"},
})
if err != nil {
panic(err)
}
fmt.Println(key) # => Psersonal access token of GitHub
}
main.go
import "github.com/pocke/gha"
func main() {
key, err := gha.CLI("key.txt", gha.Request{
Note: "hoge-app",
})
if err != nil {
panic(err)
}
fmt.Println(key)
}
Run
$ go run main.go
username: <INPUT YOUR USER NAME>
password for <YOUR USER NAME> (never stored): <INPUT YOUR PASSWORD>
<SHOW YOUR KEY>
gha.CLI
saves your key to file.
If key is saved already, gha.CLI
returns saved key.