Skip to content

Commit d9ff2bf

Browse files
fix: to scope handling for client credentials test api
1 parent 54bc96d commit d9ff2bf

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

cmd/server/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"flag"
66
"log"
77
"net/http"
8+
"strings"
89

910
"github.com/speakeasy-api/speakeasy-api-test-service/internal/acceptHeaders"
1011
"github.com/speakeasy-api/speakeasy-api-test-service/internal/clientcredentials"
@@ -87,6 +88,9 @@ func main() {
8788
bind := ":8080"
8889
if bindArg != nil {
8990
bind = *bindArg
91+
if !strings.HasPrefix(bind, ":") {
92+
bind = ":" + bind
93+
}
9094
}
9195

9296
ctx, cancel := context.WithCancel(context.Background())

internal/clientcredentials/service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func HandleTokenRequest(w http.ResponseWriter, r *http.Request) {
4545
return
4646
}
4747

48-
if !slices.Contains(scopes, "read") || !slices.Contains(scopes, "write") {
48+
if !slices.Contains(scopes, "read") && !slices.Contains(scopes, "write") {
4949
http.Error(w, "invalid_scope", http.StatusBadRequest)
5050
return
5151
}

0 commit comments

Comments
 (0)