MCPcopy Create free account
hub / github.com/cli/cli / authResultFromToken

Function authResultFromToken

internal/authflow/refresh.go:121–131  ·  view source on GitHub ↗

authResultFromToken projects the OAuth flow's access token and the resolved username onto an AuthResult. A refresh token is present only when the server honored the expiring request, so the refreshable credential is gated on it rather than on requestRefreshToken. requestedAt anchors any expiring tok

(token *oauthapi.AccessToken, username string, requestedAt time.Time)

Source from the content-addressed store, hash-verified

119// token is present only when the server honored the expiring request, so the refreshable credential is gated on it
120// rather than on requestRefreshToken. requestedAt anchors any expiring token's lifetime.
121func authResultFromToken(token *oauthapi.AccessToken, username string, requestedAt time.Time) *AuthResult {
122 result := &AuthResult{
123 Token: token.Token,
124 Username: username,
125 }
126 if token.RefreshToken != "" {
127 credential := credentialFromAccessToken(token, requestedAt)
128 result.Refreshable = &credential
129 }
130 return result
131}

Callers 2

AuthFlowFunction · 0.85
TestAuthResultFromTokenFunction · 0.85

Calls 1

Tested by 1

TestAuthResultFromTokenFunction · 0.68