Source File
token.go
Belonging Package
github.com/aws/smithy-go/auth/bearer
package bearer
import (
)
// Token provides a type wrapping a bearer token and expiration metadata.
type Token struct {
Value string
CanExpire bool
Expires time.Time
}
// Expired returns if the token's Expires time is before or equal to the time
// provided. If CanExpires is false, Expired will always return false.
func ( Token) ( time.Time) bool {
if !.CanExpire {
return false
}
= .Round(0)
return .Equal(.Expires) || .After(.Expires)
}
// TokenProvider provides interface for retrieving bearer tokens.
type TokenProvider interface {
RetrieveBearerToken(context.Context) (Token, error)
}
// TokenProviderFunc provides a helper utility to wrap a function as a type
// that implements the TokenProvider interface.
type TokenProviderFunc func(context.Context) (Token, error)
// RetrieveBearerToken calls the wrapped function, returning the Token or
// error.
func ( TokenProviderFunc) ( context.Context) (Token, error) {
return ()
}
// StaticTokenProvider provides a utility for wrapping a static bearer token
// value within an implementation of a token provider.
type StaticTokenProvider struct {
Token Token
}
// RetrieveBearerToken returns the static token specified.
func ( StaticTokenProvider) (context.Context) (Token, error) {
return .Token, nil
}
The pages are generated with Golds v0.4.9. (GOOS=linux GOARCH=amd64)