本文整理匯總了Golang中github.com/gokyle/keybase/api.Session.SignaturePostAuth方法的典型用法代碼示例。如果您正苦於以下問題:Golang Session.SignaturePostAuth方法的具體用法?Golang Session.SignaturePostAuth怎麽用?Golang Session.SignaturePostAuth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/gokyle/keybase/api.Session
的用法示例。
在下文中一共展示了Session.SignaturePostAuth方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: postAuth
func postAuth(session *api.Session, keyRing *openpgp.KeyRing) {
pub := session.User.PublicKeys["primary"]
if pub == nil {
fmt.Println("No public key for this account.")
os.Exit(1)
}
fmt.Printf("Fingerprint: %s\n", pub.Fingerprint)
signer := keyRing.Entity(pub.Fingerprint)
if signer == nil {
fmt.Println("No private key for this account.")
os.Exit(1)
}
/*
var signature = `-----BEGIN PGP MESSAGE-----
Version: Keybase Go client (OpenPGP version 0.1.0)
xA0DAAIB7k+6hRB9rTcBrQFRYgBTPJCXeyJib2R5Ijp7ImtleSI6eyJmaW5nZXJw
cmludCI6IjNiMGM0ZGU3ZDE2NThkMWE1ZmFlYzEyMGVlNGZiYTg1MTA3ZGFkMzci
LCJob3N0Ijoia2V5YmFzZS5pbyIsImtleV9pZCI6IjAxMDEwYjA0YTFmNzk2M2Nm
YjUxNjQ0ZWUyM2E0YTA2NmY1MzkxN2FmNzE1N2E5Njg5MWViYjAzNTExZTU1Yjk2
MmUzMGEiLCJ1aWQiOiI5NGVmMWUzNTc4OWM2ZmE2NThiNzhlMWIwNWVlZGUwMCIs
InVzZXJuYW1lIjoia2lzb20ifSwic3RyaW5nIjoiIiwidHlwZSI6ImF1dGgiLCJ2
ZXJzaW9uIjoxfSwiY3RpbWUiOjEzOTY0NzgwOTQsImV4cGlyZXNfaW4iOjg2NDAw
LCJ0YWciOiJzaWduYXR1cmUifcLBXAQAAQIAEAUCUzyQlwkQ7k+6hRB9rTcAANSz
EAAseFDy8srABjWmQqp4uhaOPGUDzO9E2wYWm6GcFf60KeenMkYUCssHoP12a4eB
ZLgt2ERkIFAQmn+hQkkfBSK7tQjh6XQmXstHwkhUp2XG2/Kn3Lek7t2sgaqzdt46
/qVmgymBbSgraW0JYzDC+Bta8RRfYhkYyNTjtWnx9Ue2r2R6UcTDGyTS4cWMgAVY
h1ZgQwNLfHMDqjEP93gPj9n8JZb5EN0MXGCe3Z6wMfXIams2QQ4TdsMGvwJffKel
GGOaqUYoTlE01zSF9RA53xTzqwC7PpVcOO6V7FMpRM6UQE6x1MQzy/Iz8gBZONpb
G24IkbpFj+SQYdUJ3fedTUiTWT32n/9sgp3NKY4lFdYKEDhv6fMgSLFkMhbvf6YC
d0Jd1OORtzke3MxJPDHRLlnCNdNA3ZfwD1Dx2Mu8j7JknWBdUsZK2KtDh3hijfmY
TGT1TL6fBT9DAzGfJj305rTNaYR2GnD8ncmqMCD5O+ePVFaQxyrC9zgy50UEOTNS
BLVqFj1mCE38ziBxO39Y1Kx4U0ZUmQ90Fz7nzhw3alnPQaPF6M8f+q2Mx+xuZhHF
hYddlV4afpsHp14sAeLaImLZ+IPvL+KH0f3Pc0N9rSaCJhsR5yLLpoPXk3RXrs+1
kXBuzD8AyhGVVJ+VCOuauUwRQT+Ergl7auG94uQi7SN15w==
=gRI/
-----END PGP MESSAGE-----`
*/
sigData, err := session.SignaturePostAuthData()
if err != nil {
fmt.Printf("Failed to get signature post auth data: %v\n", err)
os.Exit(1)
}
signature, err := keyRing.Sign(sigData, pub.Fingerprint)
if err != nil {
fmt.Printf("Signing failed: %v\n", err)
os.Exit(1)
}
authToken, err := session.SignaturePostAuth([]byte(signature))
if err != nil {
fmt.Printf("Posting signature authentication failed: %v\n", err)
os.Exit(1)
}
fmt.Printf("Authentication token: %x\n", authToken)
}