CreateHostAuthenticationToken
client.Runners.Configurations.HostAuthenticationTokens.New(ctx, body) (*RunnerConfigurationHostAuthenticationTokenNewResponse, error)
POST/gitpod.v1.RunnerConfigurationService/CreateHostAuthenticationToken
Creates a new authentication token for accessing remote hosts.
Use this method to:
- Set up SCM authentication
- Configure OAuth credentials
- Manage PAT tokens
Examples
-
Create OAuth token:
Creates a new OAuth-based authentication token.
runnerId: "d2c94c27-3b76-4a42-b88c-95a85e392c68" userId: "f53d2330-3795-4c5d-a1f3-453121af9c60" host: "github.com" token: "gho_xxxxxxxxxxxx" source: HOST_AUTHENTICATION_TOKEN_SOURCE_OAUTH expiresAt: "2024-12-31T23:59:59Z" refreshToken: "ghr_xxxxxxxxxxxx"
CreateHostAuthenticationToken
package main
import (
"context"
"fmt"
"time"
"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"),
)
hostAuthenticationToken, err := client.Runners.Configurations.HostAuthenticationTokens.New(context.TODO(), gitpod.RunnerConfigurationHostAuthenticationTokenNewParams{
Token: gitpod.F("gho_xxxxxxxxxxxx"),
ExpiresAt: gitpod.F(time.Now()),
Host: gitpod.F("github.com"),
RefreshToken: gitpod.F("ghr_xxxxxxxxxxxx"),
RunnerID: gitpod.F("d2c94c27-3b76-4a42-b88c-95a85e392c68"),
Source: gitpod.F(gitpod.HostAuthenticationTokenSourceOAuth),
UserID: gitpod.F("f53d2330-3795-4c5d-a1f3-453121af9c60"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", hostAuthenticationToken.Token)
}
{
"token": {
"id": "id",
"expiresAt": "2019-12-27T18:11:19.117Z",
"host": "host",
"integrationId": "integrationId",
"runnerId": "runnerId",
"scopes": [
"string"
],
"source": "HOST_AUTHENTICATION_TOKEN_SOURCE_UNSPECIFIED",
"subject": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"principal": "PRINCIPAL_UNSPECIFIED"
},
"userId": "userId"
}
}Returns Examples
{
"token": {
"id": "id",
"expiresAt": "2019-12-27T18:11:19.117Z",
"host": "host",
"integrationId": "integrationId",
"runnerId": "runnerId",
"scopes": [
"string"
],
"source": "HOST_AUTHENTICATION_TOKEN_SOURCE_UNSPECIFIED",
"subject": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"principal": "PRINCIPAL_UNSPECIFIED"
},
"userId": "userId"
}
}