doc.go raw

   1  // Package authentication provides a interface for IAM (Identity and Access Management)
   2  // token operations in sdk services.
   3  //
   4  // Core Interfaces:
   5  //
   6  // The Authenticator interface defines the main contract for token operations:
   7  //
   8  //	type Authenticator interface {
   9  //	    CreateIAMToken(ctx context.Context) (IamToken, error)
  10  //	    CreateIAMTokenForServiceAccount(ctx context.Context, serviceAccountID string) (IamToken, error)
  11  //	}
  12  //
  13  // Usage Examples:
  14  //
  15  // Creating an authenticator with endpoint:
  16  //
  17  //	auth, err := authentication.NewAuthenticatorFromEndpoint(credentials, endpoint)
  18  //	if err != nil {
  19  //	    // handle error
  20  //	}
  21  //
  22  //	// Generate token
  23  //	token, err := auth.CreateIAMToken(ctx)
  24  //
  25  // Creating an authenticator directly:
  26  //
  27  //	auth := authentication.NewAuthenticator(credentials, iamTokenClient)
  28  //	token, err := auth.CreateIAMToken(ctx)
  29  //
  30  // Error Handling:
  31  // The package uses AuthError type for detailed error reporting:
  32  //
  33  //	type AuthError struct {
  34  //	    Op  string  // Operation where error occurred
  35  //	    Err error   // Underlying error
  36  //	}
  37  //
  38  // Credential Types:
  39  // The authenticator supports two main types of credentials:
  40  //   - ExchangeableCredentials: Credentials that can be exchanged for IAM tokens
  41  //   - NonExchangeableCredentials: Credentials that directly provide IAM tokens
  42  package authentication
  43