Skip to content
DashboardGet API Key

Get current user

client.Users.GetCurrent(ctx) (*UserGetCurrentResponse, error)
GET/v1/users/me

Returns the identity associated with the authenticated API token.

ReturnsExpand Collapse
type UserGetCurrentResponse struct{…}
Name string

Display name of the API token.

Get current user

package main

import (
  "context"
  "fmt"

  "github.com/chamelaion/chamelaion-go"
  "github.com/chamelaion/chamelaion-go/option"
)

func main() {
  client := chamelaion.NewClient(
    option.WithAPIKey("My API Key"),
  )
  response, err := client.Users.GetCurrent(context.TODO())
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.Name)
}
{
  "name": "My API Token"
}
{
  "error": "missing authorization header"
}
{
  "error": "invalid authorization format"
}
{
  "error": "missing token"
}
{
  "error": "invalid token"
}
{
  "error": "unauthorized"
}
{
  "error": "internal error"
}
Returns Examples
{
  "name": "My API Token"
}
{
  "error": "missing authorization header"
}
{
  "error": "invalid authorization format"
}
{
  "error": "missing token"
}
{
  "error": "invalid token"
}
{
  "error": "unauthorized"
}
{
  "error": "internal error"
}