Skip to content
Ona Docs

GetAuthenticatedIdentity

client.Identity.GetAuthenticatedIdentity(ctx, body) (*IdentityGetAuthenticatedIdentityResponse, error)
POST/gitpod.v1.IdentityService/GetAuthenticatedIdentity

Retrieves information about the currently authenticated identity.

Use this method to:

  • Get current user information
  • Check authentication status
  • Retrieve organization context
  • Validate authentication principal

Examples

  • Get current identity:

    Retrieves details about the authenticated user.

    {}
ParametersExpand Collapse
body IdentityGetAuthenticatedIdentityParams
Empty param.Field[bool]Optional
ReturnsExpand Collapse
type IdentityGetAuthenticatedIdentityResponse struct{…}
OrganizationID stringOptional
OrganizationTier stringOptional
Subject SubjectOptional

subject is the identity of the current user

ID stringOptional

id is the UUID of the subject

formatuuid
Principal PrincipalOptional

Principal is the principal of the subject

One of the following:
const PrincipalUnspecified Principal = "PRINCIPAL_UNSPECIFIED"
const PrincipalAccount Principal = "PRINCIPAL_ACCOUNT"
const PrincipalUser Principal = "PRINCIPAL_USER"
const PrincipalRunner Principal = "PRINCIPAL_RUNNER"
const PrincipalEnvironment Principal = "PRINCIPAL_ENVIRONMENT"
const PrincipalServiceAccount Principal = "PRINCIPAL_SERVICE_ACCOUNT"
const PrincipalRunnerManager Principal = "PRINCIPAL_RUNNER_MANAGER"

GetAuthenticatedIdentity

package main

import (
  "context"
  "fmt"

  "github.com/gitpod-io/gitpod-sdk-go"
  "github.com/gitpod-io/gitpod-sdk-go/option"
)

func main() {
  client := gitpod.NewClient(
    option.WithBearerToken("My Bearer Token"),
  )
  response, err := client.Identity.GetAuthenticatedIdentity(context.TODO(), gitpod.IdentityGetAuthenticatedIdentityParams{

  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.OrganizationID)
}
{
  "organizationId": "organizationId",
  "organizationTier": "organizationTier",
  "subject": {
    "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "principal": "PRINCIPAL_UNSPECIFIED"
  }
}
Returns Examples
{
  "organizationId": "organizationId",
  "organizationTier": "organizationTier",
  "subject": {
    "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "principal": "PRINCIPAL_UNSPECIFIED"
  }
}