Authentication
Learn how to authenticate to Simple OKR before you can use the APIs
Last updated
Was this helpful?
Was this helpful?
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"strings"
"time"
)
func hmacSign(secret string, data string) string {
mac := hmac.New(sha256.New, []byte(secret))
mac.Write([]byte(data))
return strings.ToLower(hex.EncodeToString(mac.Sum(nil)))
}
func main() {
credential := "mycredential"
secret := "mysecret"
timestamp := time.Now().UTC().Format(time.RFC3339)
signature := hmacSign(secret, credential+timestamp)
println(credential, secret, timestamp, signature)
}import hmac
import hashlib
credential = b"mycredential"
secret = b"mysecret"
timestamp = b"2019-02-03T01:55:37Z"
mac = hmac.new(bytearray(secret), digestmod=hashlib.sha256)
mac.update(bytearray(credential + timestamp))
digest = mac.hexdigest()
print(credential, secret, timestamp, digest)