MCPcopy Create free account
hub / github.com/docker/docker-agent / printOAuthListText

Function printOAuthListText

cmd/root/debug_oauth.go:101–124  ·  view source on GitHub ↗
(w io.Writer, entries []mcp.OAuthTokenEntry)

Source from the content-addressed store, hash-verified

99}
100
101func printOAuthListText(w io.Writer, entries []mcp.OAuthTokenEntry) {
102 for i, e := range entries {
103 if i > 0 {
104 fmt.Fprintln(w)
105 }
106 fmt.Fprintf(w, "Resource: %s\n", e.ResourceURL)
107 if e.Token.TokenType != "" {
108 fmt.Fprintf(w, "Token Type: %s\n", e.Token.TokenType)
109 }
110 if e.Token.Scope != "" {
111 fmt.Fprintf(w, "Scope: %s\n", e.Token.Scope)
112 }
113 fmt.Fprintf(w, "Access Token: %s\n", truncateToken(e.Token.AccessToken))
114 fmt.Fprintf(w, "Refresh Token: %v\n", e.Token.RefreshToken != "")
115 if !e.Token.ExpiresAt.IsZero() {
116 fmt.Fprintf(w, "Expires at: %s\n", e.Token.ExpiresAt.Local().Format(time.RFC3339))
117 }
118 if e.Token.IsExpired() {
119 fmt.Fprintln(w, "Status: ❌ Expired")
120 } else {
121 fmt.Fprintln(w, "Status: ✅ Valid")
122 }
123 }
124}
125
126func truncateToken(token string) string {
127 const previewLen = 10

Callers 1

newDebugOAuthListCmdFunction · 0.85

Calls 3

truncateTokenFunction · 0.85
IsExpiredMethod · 0.80
IsZeroMethod · 0.45

Tested by

no test coverage detected