Skip to content

Commit 1b79a57

Browse files
committed
add ValidateApiKey method
1 parent d9106b3 commit 1b79a57

3 files changed

Lines changed: 498 additions & 314 deletions

File tree

client.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@ func (c *MeterusClient) ListMeterSubjects(ctx context.Context, meterIDOrSlug str
9393
return c.client.ListMeterSubjects(ctx, &pb.ListMeterSubjectsRequest{MeterIdOrSlug: meterIDOrSlug})
9494
}
9595

96+
func (c *MeterusClient) ValidateApiKey(ctx context.Context, api_key string, scopes []string) (*pb.ValidateApiKeyResponse, error) {
97+
// Create a new context with only the provided API key
98+
md := metadata.New(map[string]string{
99+
"Authorization": fmt.Sprintf("Bearer %s", api_key),
100+
})
101+
ctx = metadata.NewOutgoingContext(ctx, md)
102+
return c.client.ValidateApiKey(ctx, &pb.ValidateApiKeyRequest{RequiredScopes: scopes})
103+
}
104+
96105
// NewCloudEvent creates a new CloudEvent with the given parameters.
97106
func NewCloudEvent(id, source, specVersion, eventType string, time time.Time, subject string, data map[string]any) (*pb.CloudEvent, error) {
98107
// Convert the data map to a protobuf Struct

0 commit comments

Comments
 (0)