You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: policy_key_credential.go
    path of file: ./repos/azure-sdk-for-go/sdk/messaging/azwebpubsub/internal
    
    the code of the file until where you have to start completion: // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package internal

import (
	"errors"
	"net/http"
	"time"

	"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
	"github.com/Azure/azure-sdk-for-go/sdk/internal/errorinfo"
	"github.com/golang-jwt/jwt/v5"
)

type KeyCredentialPolicy struct {
	key string
    
func (k *KeyCredentialPolicy) Do(req *policy.Request) (*http.Response, error) {
	val := k.key
	token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{
		"aud": req.Raw().URL.String(),
		"exp": time.Now().Add(time.Hour).Unix(),
	})
	secretKey := []byte(val) // Replace with your secret key
	tokenString, err := token.SignedString(secretKey)
	if err != nil {
		return nil, errorinfo.NonRetriableError(errors.New("error signing the token"))
	}
	req.Raw().Header.Add("Authorization", "Bearer "+tokenString)
	return req.Next()
}