Skip to content

Commit

Permalink
Implement connector's Validate method
Browse files Browse the repository at this point in the history
  • Loading branch information
martinalbert committed Apr 24, 2023
1 parent bb866ee commit 24e2fd6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/connector/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
v2 "github.com/conductorone/baton-sdk/pb/c1/connector/v2"
"github.com/conductorone/baton-sdk/pkg/annotations"
"github.com/conductorone/baton-sdk/pkg/connectorbuilder"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)

var (
Expand Down Expand Up @@ -52,6 +54,12 @@ func (pd *PagerDuty) Metadata(ctx context.Context) (*v2.ConnectorMetadata, error

// Validate hits the PagerDuty API to validate that the configured credentials are still valid.
func (pd *PagerDuty) Validate(ctx context.Context) (annotations.Annotations, error) {
_, err := pd.client.ListUsersWithContext(ctx, pagerduty.ListUsersOptions{})

if err != nil {
return nil, status.Error(codes.Unauthenticated, "Provided Access Token is invalid")
}

return nil, nil
}

Expand Down

0 comments on commit 24e2fd6

Please sign in to comment.