Skip to content

Commit

Permalink
add access token to debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
patdowney committed Oct 31, 2024
1 parent 9de3d05 commit 87eab1e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"log/slog"
"net/http"
"time"

"github.com/auth0/go-jwt-middleware/v2/validator"
"golang.org/x/oauth2"
Expand All @@ -21,6 +22,8 @@ type DebugStruct struct {
Errors []string `json:",omitempty"`
RegisteredClaims validator.RegisteredClaims `json:",omitempty"`
Claims jwt2.Claims `json:",omitempty"`
AccessToken string `json:",omitempty"`
Expiry time.Time `json:",omitempty"`
}

func FlyValidator() (jwt.TokenValidator, error) {
Expand Down Expand Up @@ -57,10 +60,14 @@ func FlyDebug() http.HandlerFunc {

token, err = tokenSource.Token()

o.AccessToken = token.AccessToken
o.Expiry = token.Expiry

if err != nil {
slog.Error("error getting token", "error", err)
o.Errors = append(o.Errors, fmt.Errorf("error getting token: %w", err).Error())
}

if token != nil {
jwtToken, err := jwt2.ParseSigned(token.AccessToken)
if err != nil {
Expand Down

0 comments on commit 87eab1e

Please sign in to comment.