Login
5-Line Core
result = await gateway.authenticate(
credentials=PasswordCredentials(email="alice@example.com", password="SecurePass123"),
organization_id="default",
)
user, token = result.unwrap()Step-by-Step
1
from gl_iam import IAMGateway
from gl_iam.core.types import PasswordCredentials
from gl_iam.providers.postgresql import PostgreSQLProvider, PostgreSQLConfig
config = PostgreSQLConfig(
database_url="postgresql+asyncpg://postgres:postgres@localhost:5432/gliam"
)
provider = PostgreSQLProvider(config)
gateway = IAMGateway.from_fullstack_provider(provider)2
result = await gateway.authenticate(
credentials=PasswordCredentials(
email="alice@example.com",
password="SecurePass123"
),
organization_id="default",
)3
if result.is_ok:
user, token = result.unwrap()
print(f"Welcome, {user.display_name}!")
print(f"Access token: {token.access_token[:20]}...")
else:
print(f"Login failed: {result.error.message}")4
Welcome, Alice!
Access token: eyJhbGciOiJIUzI1N...Complete Example
Common Pitfalls
Pitfall
Solution
Next Steps
Last updated
Was this helpful?