Skip to content
Ona Docs

CreateEnvironmentAccessToken

client.Environments.NewEnvironmentToken(ctx, body) (*EnvironmentNewEnvironmentTokenResponse, error)
POST/gitpod.v1.EnvironmentService/CreateEnvironmentAccessToken

Creates an access token for the environment.

Generated tokens are valid for one hour and provide environment-specific access permissions. The token is scoped to a specific environment.

Examples

  • Generate environment token:

    Creates a temporary access token for accessing an environment.

    environmentId: "07e03a28-65a5-4d98-b532-8ea67b188048"
ParametersExpand Collapse
body EnvironmentNewEnvironmentTokenParams
EnvironmentID param.Field[string]

environment_id specifies the environment for which the access token should be created.

formatuuid
ReturnsExpand Collapse
type EnvironmentNewEnvironmentTokenResponse struct{…}
AccessToken string

access_token is the token that can be used for environment authentication

CreateEnvironmentAccessToken

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.Environments.NewEnvironmentToken(context.TODO(), gitpod.EnvironmentNewEnvironmentTokenParams{
    EnvironmentID: gitpod.F("07e03a28-65a5-4d98-b532-8ea67b188048"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.AccessToken)
}
{
  "accessToken": "accessToken"
}
Returns Examples
{
  "accessToken": "accessToken"
}