Documentation
¶
Overview ¶
Package grant is the source of the access tokens of a sign-in, which is stored as a credential, such as by POST /credential/{key}/signin: the token is refreshed, with the secret of the client, which is another credential, and stored again, once it has expired.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Server authclient.ServerMetadata // The authorization server, such as Google
Client string // The key of the credential of its OAuth client, such as GOOGLE_CLIENT
Key string // The key of the credential of the sign-in, such as GOOGLE_TOKEN
Required []string // The sign-in has one of these scopes
Scopes []string // The scopes which are asked for, when signing in
}
Config is the sign-in which a source's tokens are of
type Credentials ¶
type Credentials interface {
// Get returns the credential for the key, as JSON
Get(ctx context.Context, key string) (json.RawMessage, error)
// Set stores the credential for the key, which is JSON
Set(ctx context.Context, key string, value json.RawMessage) error
}
Credentials are what a source reads its client, and sign-in, from, and stores the sign-in to, which a credential.CredentialProvider is
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
Source is the source of the access tokens of a sign-in, which is safe to use from more than one goroutine
func New ¶
New returns the source of the access tokens of the sign-in, which must be the server's, for the client, and have one of the required scopes. Returns a SignInError, with how to sign in, which wraps ErrInvalidProvider, when the person hasn't, or their sign-in is for another client, or doesn't have the scopes. Returns ErrServiceUnavailable when there are no credentials, or no client, as no one can sign in, and ErrBadParameter when the client isn't one.
func (*Source) SignIn ¶
SignIn returns a SignInError, which wraps the error, with how to sign in again, such as when an API doesn't accept the token, as it's revoked
func (*Source) Token ¶
Token returns the sign-in's token, which is refreshed, and stored, under the key's credential.Lock, once it has expired. A sign-in which was replaced while it was refreshed, such as when the person signed in again, is used, rather than overwritten. Returns a SignInError when the sign-in is revoked, or expired, and ErrServiceUnavailable when the server refuses the client, such as when its secret is wrong, which signing in again doesn't mend, or the server fails.