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

Function credentialFromAccessToken

internal/authflow/refresh.go:106–116  ·  view source on GitHub ↗

credentialFromAccessToken projects an OAuth access token onto gh.Credential, reusing refreshableCredentialFromAccessToken so the expiry mapping lives in one place. requestedAt is the instant the exchange was initiated, used to anchor the token lifetime. The runtime-only Source is left unset; the sto

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

Source from the content-addressed store, hash-verified

104// exchange was initiated, used to anchor the token lifetime. The runtime-only Source is left unset; the storage layer
105// drops it regardless.
106func credentialFromAccessToken(token *oauthapi.AccessToken, requestedAt time.Time) gh.Credential {
107 rc := refreshableCredentialFromAccessToken(token, requestedAt)
108 return gh.Credential{
109 Token: rc.AccessToken,
110 RefreshToken: rc.RefreshToken,
111 ExpiresIn: rc.ExpiresIn,
112 RefreshTokenExpiresIn: rc.RefreshTokenExpiresIn,
113 ExpiresAt: rc.ExpiresAt,
114 RefreshTokenExpiresAt: rc.RefreshTokenExpiresAt,
115 }
116}
117
118// authResultFromToken projects the OAuth flow's access token and the resolved username onto an AuthResult. A refresh
119// token is present only when the server honored the expiring request, so the refreshable credential is gated on it

Callers 1

authResultFromTokenFunction · 0.85

Tested by

no test coverage detected