Skip to content

Authentication

The SDK authenticates using bearer tokens. No OAuth, no API keys — just a token string.

from githosted import Client
# Pass a token directly
client = Client(token="gw_your_token")
# Or set GITHOSTED_TOKEN in your environment
# export GITHOSTED_TOKEN=gw_your_token
client = Client()
PrefixTypeScopeUse case
gw_WorkspaceAll repos in workspaceApps, agents, admin tools
gr_RepoSpecific repos onlyCI jobs, sandboxes, least-privilege

Both token types work in the same Client constructor. The SDK auto-detects the type from the prefix.

The SDK resolves credentials in this order (first match wins):

  1. Explicit: Client(token="gw_xxx")
  2. Environment: GITHOSTED_TOKEN env var

For local development or self-hosted instances:

client = Client(
token="gw_xxx",
base_url="http://localhost:8080",
)

The default base URL is https://api.githosted.dev.