security/utils.go
func EncodeOAuth2Code(clientID, redirectURI, userID, sharedKey string) (code string, err error) {
	rand := RandStringBytesMaskImprSrc(20)
	exp := time.Now().Add(time.Minute * 10).String()
	response := NewResponse(clientID, redirectURI, userID, exp, rand)
	jresponse, err := json.Marshal(response)
	if err != nil {
		log.Printf("Error: %v", err)
	}
	j64response := base64.StdEncoding.EncodeToString(jresponse)
	signer, err := jose.NewSigner(jose.SigningKey{Algorithm: jose.HS512, Key: []byte(sharedKey)}, nil)
	if err != nil {
		log.Printf("Error: %v", err)
	}
	object, err := signer.Sign([]byte(j64response))
	if err != nil {
		log.Printf("Error: %v", err)
	}
	code, err = object.CompactSerialize()
	return
}
func EncodeOAuth2Code(clientID, redirectURI, userID, sharedKey string) (code string, err error) {
	rand := RandStringBytesMaskImprSrc(20)
	exp := time.Now().Add(time.Minute * 10).String()
	response := NewResponse(clientID, redirectURI, userID, exp, rand)
	jresponse, err := json.Marshal(response)
	if err != nil {
		log.Printf("Error: %v", err)
	}
	j64response := base64.StdEncoding.EncodeToString(jresponse)
	signer, err := jose.NewSigner(jose.SigningKey{Algorithm: jose.HS512, Key: []byte(sharedKey)}, nil)
	if err != nil {
		log.Printf("Error: %v", err)
	}
	object, err := signer.Sign([]byte(j64response))
	if err != nil {
		log.Printf("Error: %v", err)
	}
	code, err = object.CompactSerialize()
	return
}
//EncodeOAuth2Code generate an OAuth2 code