Cloud Authentication
Authenticate with Postbase Cloud using GitHub OAuth.
Overview
Postbase uses GitHub OAuth with the device flow for CLI authentication:
- Run
postbase cloud login - Open the provided URL in your browser
- Enter the verification code
- Authorize the Postbase application
- CLI receives access token
Login Process
Step 1: Start Authentication
postbase cloud loginOutput:
Authenticating with Postbase Cloud...
Open this URL in your browser:
https://github.com/login/device
Enter this code: ABCD-1234
Waiting for authorization... (press Ctrl+C to cancel)Step 2: Enter Code
- Open https://github.com/login/device
- Enter the code shown in terminal (e.g.,
ABCD-1234) - Click "Continue"
Step 3: Authorize
- Review the permissions requested
- Click "Authorize postbase"
- CLI automatically completes
Step 4: Confirmation
✓ Authenticated as username
Welcome to Postbase Cloud!
Run 'postbase cloud projects list' to get started.Permissions
Postbase requests minimal GitHub permissions:
| Scope | Purpose |
|---|---|
read:user | Get your username and email |
user:email | Access verified email addresses |
We do not request access to your repositories or organizations.
Token Storage
Access tokens are stored locally:
~/.postbase/cloud.jsonThis file contains:
{
"access_token": "pb_xxx...",
"user": {
"id": "user_xxx",
"login": "username",
"email": "user@example.com"
}
}Logout
Clear stored credentials:
postbase cloud logout✓ Logged out from Postbase CloudThis removes ~/.postbase/cloud.json.
Check Current User
View your authenticated account:
postbase cloud whoamiLogged in as: username
Email: user@example.com
User ID: user_xxxToken Refresh
Tokens are long-lived and don't expire automatically. If you need a fresh token:
postbase cloud logout
postbase cloud loginProgrammatic Access
Using the Token
const token = process.env.POSTBASE_TOKEN
const response = await fetch('https://api.postbase.sh/projects', {
headers: {
'Authorization': `Bearer ${token}`
}
})Environment Variables
Set POSTBASE_TOKEN for CI/CD:
export POSTBASE_TOKEN="pb_xxx..."
# CLI will use this token instead of stored credentials
postbase cloud projects listCI/CD Integration
GitHub Actions
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install Postbase CLI
run: npm install -g postbase
- name: Run Migrations
env:
POSTBASE_TOKEN: ${{ secrets.POSTBASE_TOKEN }}
run: |
postbase cloud migrate up \
-p my-project \
-d productionGetting a Token for CI
- Log in locally:
postbase cloud login - Copy token from
~/.postbase/cloud.json - Add as secret in your CI platform
Multiple Accounts
Currently, Postbase supports one account at a time. Switch accounts by logging out and in:
postbase cloud logout
postbase cloud login # Log in with different GitHub accountTroubleshooting
Login Stuck
If the CLI is waiting forever:
- Check browser completed authorization
- Try refreshing the GitHub page
- Press Ctrl+C and retry
Invalid Token
If you see 401 Unauthorized:
# Re-authenticate
postbase cloud logout
postbase cloud loginToken Missing
If credentials file is missing:
# Re-authenticate to create new file
postbase cloud loginGitHub OAuth Error
If GitHub shows an error:
- Ensure you're logged into GitHub
- Try a different browser
- Clear browser cookies for github.com
- Contact support if persistent