Skip to main content

Authentication

Protected operations accept a personal API token or a session JWT. Pass the raw value through ContextAccessToken. The SDK adds Authorization: Bearer … automatically.

import (
"context"

analogwakatime "github.com/Analog-Code-Monitor/Analog-WakaTime-GO-SDK"
)

const apiToken = "PASTE_API_TOKEN_HERE"

ctx := context.WithValue(
context.Background(),
analogwakatime.ContextAccessToken,
apiToken,
)
client := analogwakatime.NewAPIClient(analogwakatime.NewConfiguration())

Reuse the same ctx and client for subsequent authenticated calls.

Auth schemes in the OpenAPI contract

The generated client documents two Bearer schemes that both use ContextAccessToken:

  • bearerAuth — session JWT
  • apiTokenAuth — personal API token (analog-wakatime_live_…)

Do not prefix the value with Bearer ; the SDK builds the header.

Unauthenticated calls

Public endpoints (health checks, public statistics, OAuth start URLs, device flow polling) can use context.Background() without a token.

Create and manage tokens with API tokens after you are authenticated.