Skip to content
Ona Docs

GetIDToken

client.identity.getIDToken(IdentityGetIDTokenParams { audience, version } body, RequestOptionsoptions?): IdentityGetIDTokenResponse { token }
POST/gitpod.v1.IdentityService/GetIDToken

Gets an ID token for authenticating with other services.

Use this method to:

  • Obtain authentication tokens for service-to-service calls
  • Access protected resources
  • Generate scoped access tokens

Examples

  • Get token for single service:

    Retrieves a token for authenticating with one service.

    audience:
      - "https://api.gitpod.io"
  • Get token for multiple services:

    Retrieves a token valid for multiple services.

    audience:
      - "https://api.gitpod.io"
      - "https://ws.gitpod.io"
ParametersExpand Collapse
body: IdentityGetIDTokenParams { audience, version }
audience?: Array<string>
version?: IDTokenVersion

version is the version of the ID token.

One of the following:
"ID_TOKEN_VERSION_UNSPECIFIED"
"ID_TOKEN_VERSION_V1"
"ID_TOKEN_VERSION_V2"
ReturnsExpand Collapse
IdentityGetIDTokenResponse { token }
token?: string

GetIDToken

import Gitpod from '@gitpod/sdk';

const client = new Gitpod({
  bearerToken: process.env['GITPOD_API_KEY'], // This is the default and can be omitted
});

const response = await client.identity.getIDToken({
  audience: ['https://api.gitpod.io', 'https://ws.gitpod.io'],
});

console.log(response.token);
{
  "token": "token"
}
Returns Examples
{
  "token": "token"
}