Skip to content

How to authenticate with the API

All API clients require credentials. The SDK supports two authentication methods.

Pass your API token when creating a client:

from owi.metadatabase.geometry.io import GeometryAPI

api = GeometryAPI(token="your-api-token")

You can also pass a pre-built header dictionary:

api = GeometryAPI(header={"Authorization": "Token your-api-token"})

Username and password authentication

api = GeometryAPI(uname="your-username", password="your-password")

Store credentials securely

Avoid hard-coding tokens in source files. Use environment variables instead:

import os
from owi.metadatabase.geometry.io import GeometryAPI

TOKEN = os.environ["OWI_API_TOKEN"]
api = GeometryAPI(token=TOKEN)

Warning

Never commit real API tokens to version control.