Skip to content

Commit

Permalink
fix: to scope handling for client credentials test api
Browse files Browse the repository at this point in the history
  • Loading branch information
TristanSpeakEasy committed Feb 6, 2025
1 parent 54bc96d commit d9ff2bf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"flag"
"log"
"net/http"
"strings"

"github.com/speakeasy-api/speakeasy-api-test-service/internal/acceptHeaders"
"github.com/speakeasy-api/speakeasy-api-test-service/internal/clientcredentials"
Expand Down Expand Up @@ -87,6 +88,9 @@ func main() {
bind := ":8080"
if bindArg != nil {
bind = *bindArg
if !strings.HasPrefix(bind, ":") {
bind = ":" + bind
}
}

ctx, cancel := context.WithCancel(context.Background())
Expand Down
2 changes: 1 addition & 1 deletion internal/clientcredentials/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func HandleTokenRequest(w http.ResponseWriter, r *http.Request) {
return
}

if !slices.Contains(scopes, "read") || !slices.Contains(scopes, "write") {
if !slices.Contains(scopes, "read") && !slices.Contains(scopes, "write") {
http.Error(w, "invalid_scope", http.StatusBadRequest)
return
}
Expand Down

0 comments on commit d9ff2bf

Please sign in to comment.