Integration with Gatsby Cloud for authentication, user management, and cloud service access. These features are experimental and require the GATSBY_EXPERIMENTAL_CLOUD_CLI environment variable.
Authenticate with Gatsby Cloud using browser-based OAuth flow.
/**
* Authenticate with Gatsby Cloud
* Opens browser for OAuth authentication and stores access token
*/
gatsby loginUsage Examples:
# Enable cloud CLI features
export GATSBY_EXPERIMENTAL_CLOUD_CLI=true
# Login to Gatsby Cloud
gatsby loginAuthentication Flow:
Authentication Process:
/**
* Authentication ticket system
* Temporary session for secure browser-based authentication
*/
interface AuthenticationTicket {
ticketId: string; // Unique ticket identifier
verified: boolean; // Authentication completion status
token?: string | null; // Access token (when verified)
expiration?: string | null; // Token expiration date
}
/**
* Create authentication ticket
* @returns Promise resolving to ticket ID
*/
function createTicket(): Promise<string>;
/**
* Check ticket verification status
* @param ticketId - Ticket identifier to check
* @returns Promise resolving to ticket status
*/
function getTicket(ticketId: string): Promise<AuthenticationTicket>;Browser Integration:
Remove stored authentication credentials and sign out of Gatsby Cloud services.
/**
* Sign out of Gatsby Cloud
* Removes stored access token and clears authentication state
*/
gatsby logoutUsage Examples:
# Logout from Gatsby Cloud
gatsby logoutLogout Process:
Display information about the currently authenticated Gatsby Cloud user.
/**
* Display current user information
* Shows username of authenticated Gatsby Cloud user
*/
gatsby whoamiUsage Examples:
# Check current user
gatsby whoami
# Example output
# john.doe@example.comUser Information Retrieval:
/**
* Fetch current user information from Gatsby Cloud
* @param token - Access token for authentication
* @returns Promise resolving to username
*/
function getUsername(token: string): Promise<string>;GraphQL Query for User Data:
query {
currentUser {
name
}
}Secure storage and management of authentication tokens.
/**
* Token management functions
* Secure storage of authentication credentials
*/
interface TokenManager {
getToken(): Promise<string>; // Retrieve stored token
setToken(token: string | null, expiration: string): void; // Store token with expiration
}
/**
* Token storage structure
*/
interface TokenStorage {
token: string | null; // Access token
expiration: string; /* Expiration date*/
}Token Features:
Configuration Storage:
Comprehensive error handling for authentication operations.
Login Errors:
/**
* Authentication error types
*/
type AuthenticationError =
| "NetworkError" // Cannot connect to Gatsby Cloud
| "BrowserError" // Cannot open browser
| "TimeoutError" // Authentication timeout
| "TokenError" // Invalid or expired token
| "UserCancelledError"; // User cancelled authenticationCommon Error Scenarios:
Error Messages:
# Network error example
We had trouble connecting to Gatsby Cloud to create a login session.
Please try again later, and if it continues to have trouble connecting file an issue.
# Already logged in
You are already logged in!
# Not logged in (whoami)
You are not currently logged in!
# Token expired warning
Your token has expired, you may need to login againSetup and configuration for Gatsby Cloud CLI features.
Environment Variables:
/**
* Required environment configuration
*/
interface CloudConfiguration {
GATSBY_EXPERIMENTAL_CLOUD_CLI: string; // Enable cloud features ("true")
}Setup Examples:
# Enable cloud CLI features permanently
echo 'export GATSBY_EXPERIMENTAL_CLOUD_CLI=true' >> ~/.bashrc
source ~/.bashrc
# Enable for current session only
export GATSBY_EXPERIMENTAL_CLOUD_CLI=true
# Enable for single command
GATSBY_EXPERIMENTAL_CLOUD_CLI=true gatsby loginFeature Availability:
Integration with Gatsby Cloud services and APIs.
Service Endpoints:
/**
* Gatsby Cloud service endpoints
*/
interface GatsbyCloudEndpoints {
authService: "https://auth.gatsbyjs.com"; // Authentication service
apiService: "https://api.gatsbyjs.com"; // GraphQL API service
webService: "https://gatsbyjs.com"; // Web interface
}API Authentication:
Authentication URLs:
POST /auth/tickets/createGET /auth/tickets/{ticketId}/dashboard/login?authType=EXTERNAL_AUTH&ticketId={id}Security best practices for cloud authentication.
Token Security:
Network Security:
Browser Security:
Integration with common Gatsby development workflows.
CI/CD Integration:
Team Collaboration: