Skip to content
Ona Docs

ExchangeToken

client.Identity.ExchangeToken(ctx, body) (*IdentityExchangeTokenResponse, error)
POST/gitpod.v1.IdentityService/ExchangeToken

Exchanges an exchange token for a new access token.

Use this method to:

  • Convert exchange tokens to access tokens
  • Obtain new access credentials
  • Complete token exchange flows

Examples

  • Exchange token:

    Trades an exchange token for an access token.

    exchangeToken: "exchange-token-value"
ParametersExpand Collapse
body IdentityExchangeTokenParams
ExchangeToken param.Field[string]Optional

exchange_token is the token to exchange

ReturnsExpand Collapse
type IdentityExchangeTokenResponse struct{…}
AccessToken stringOptional

access_token is the new access token

ExchangeToken

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.ExchangeToken(context.TODO(), gitpod.IdentityExchangeTokenParams{
    ExchangeToken: gitpod.F("exchange-token-value"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.AccessToken)
}
{
  "accessToken": "accessToken"
}
Returns Examples
{
  "accessToken": "accessToken"
}