telnyx-oauth-go

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
<!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. -->
<!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. -->

Telnyx Oauth - Go

Telnyx Oauth - Go

Installation

安装

bash
go get github.com/team-telnyx/telnyx-go
bash
go get github.com/team-telnyx/telnyx-go

Setup

初始化配置

go
import (
  "context"
  "fmt"
  "os"

  "github.com/team-telnyx/telnyx-go"
  "github.com/team-telnyx/telnyx-go/option"
)

client := telnyx.NewClient(
  option.WithAPIKey(os.Getenv("TELNYX_API_KEY")),
)
All examples below assume
client
is already initialized as shown above.
go
import (
  "context"
  "fmt"
  "os"

  "github.com/team-telnyx/telnyx-go"
  "github.com/team-telnyx/telnyx-go/option"
)

client := telnyx.NewClient(
  option.WithAPIKey(os.Getenv("TELNYX_API_KEY")),
)
以下所有示例都默认
client
已经按照上述方式完成初始化。

Error Handling

错误处理

All API calls can fail with network errors, rate limits (429), validation errors (422), or authentication errors (401). Always handle errors in production code:
go
import "errors"

result, err := client.Messages.Send(ctx, params)
if err != nil {
  var apiErr *telnyx.Error
  if errors.As(err, &apiErr) {
    switch apiErr.StatusCode {
    case 422:
      fmt.Println("Validation error — check required fields and formats")
    case 429:
      // Rate limited — wait and retry with exponential backoff
      fmt.Println("Rate limited, retrying...")
    default:
      fmt.Printf("API error %d: %s\n", apiErr.StatusCode, apiErr.Error())
    }
  } else {
    fmt.Println("Network error — check connectivity and retry")
  }
}
Common error codes:
401
invalid API key,
403
insufficient permissions,
404
resource not found,
422
validation error (check field formats),
429
rate limited (retry with exponential backoff).
所有API调用都可能失败,原因包括网络错误、速率限制(429)、校验错误(422)、或认证错误(401)。在生产环境代码中请务必处理错误:
go
import "errors"

result, err := client.Messages.Send(ctx, params)
if err != nil {
  var apiErr *telnyx.Error
  if errors.As(err, &apiErr) {
    switch apiErr.StatusCode {
    case 422:
      fmt.Println("Validation error — check required fields and formats")
    case 429:
      // Rate limited — wait and retry with exponential backoff
      fmt.Println("Rate limited, retrying...")
    default:
      fmt.Printf("API error %d: %s\n", apiErr.StatusCode, apiErr.Error())
    }
  } else {
    fmt.Println("Network error — check connectivity and retry")
  }
}
常见错误码:
401
无效API密钥,
403
权限不足,
404
资源不存在,
422
校验错误(请检查字段格式),
429
触发速率限制(使用指数退避策略重试)。

Important Notes

重要说明

  • Pagination: Use
    ListAutoPaging()
    for automatic iteration:
    iter := client.Resource.ListAutoPaging(ctx, params); for iter.Next() { item := iter.Current() }
    .
  • 分页: 使用
    ListAutoPaging()
    进行自动遍历:
    iter := client.Resource.ListAutoPaging(ctx, params); for iter.Next() { item := iter.Current() }

Authorization server metadata

授权服务器元数据

OAuth 2.0 Authorization Server Metadata (RFC 8414)
GET /.well-known/oauth-authorization-server
go
	response, err := client.WellKnown.GetAuthorizationServerMetadata(context.Background())
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.AuthorizationEndpoint)
Returns:
authorization_endpoint
(uri),
code_challenge_methods_supported
(array[string]),
grant_types_supported
(array[string]),
introspection_endpoint
(uri),
issuer
(uri),
jwks_uri
(uri),
registration_endpoint
(uri),
response_types_supported
(array[string]),
scopes_supported
(array[string]),
token_endpoint
(uri),
token_endpoint_auth_methods_supported
(array[string])
OAuth 2.0授权服务器元数据(RFC 8414)
GET /.well-known/oauth-authorization-server
go
	response, err := client.WellKnown.GetAuthorizationServerMetadata(context.Background())
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.AuthorizationEndpoint)
返回值:
authorization_endpoint
(uri类型),
code_challenge_methods_supported
(字符串数组类型),
grant_types_supported
(字符串数组类型),
introspection_endpoint
(uri类型),
issuer
(uri类型),
jwks_uri
(uri类型),
registration_endpoint
(uri类型),
response_types_supported
(字符串数组类型),
scopes_supported
(字符串数组类型),
token_endpoint
(uri类型),
token_endpoint_auth_methods_supported
(字符串数组类型)

Protected resource metadata

受保护资源元数据

OAuth 2.0 Protected Resource Metadata for resource discovery
GET /.well-known/oauth-protected-resource
go
	response, err := client.WellKnown.GetProtectedResourceMetadata(context.Background())
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.AuthorizationServers)
Returns:
authorization_servers
(array[string]),
resource
(uri)
用于资源发现的OAuth 2.0受保护资源元数据
GET /.well-known/oauth-protected-resource
go
	response, err := client.WellKnown.GetProtectedResourceMetadata(context.Background())
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.AuthorizationServers)
返回值:
authorization_servers
(字符串数组类型),
resource
(uri类型)

OAuth authorization endpoint

OAuth授权端点

OAuth 2.0 authorization endpoint for the authorization code flow
GET /oauth/authorize
go
	err := client.OAuth.GetAuthorize(context.Background(), telnyx.OAuthGetAuthorizeParams{
		ClientID: "550e8400-e29b-41d4-a716-446655440000",
		RedirectUri:  "https://example.com",
		ResponseType: telnyx.OAuthGetAuthorizeParamsResponseTypeCode,
	})
	if err != nil {
		log.Fatal(err)
	}
用于授权码流程的OAuth 2.0授权端点
GET /oauth/authorize
go
	err := client.OAuth.GetAuthorize(context.Background(), telnyx.OAuthGetAuthorizeParams{
		ClientID: "550e8400-e29b-41d4-a716-446655440000",
		RedirectUri:  "https://example.com",
		ResponseType: telnyx.OAuthGetAuthorizeParamsResponseTypeCode,
	})
	if err != nil {
		log.Fatal(err)
	}

Get OAuth consent token

获取OAuth consent token

Retrieve details about an OAuth consent token
GET /oauth/consent/{consent_token}
go
	oauth, err := client.OAuth.Get(context.Background(), "consent_token")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", oauth.Data)
Returns:
client_id
(string),
logo_uri
(uri),
name
(string),
policy_uri
(uri),
redirect_uri
(uri),
requested_scopes
(array[object]),
tos_uri
(uri),
verified
(boolean)
获取OAuth consent token的详细信息
GET /oauth/consent/{consent_token}
go
	oauth, err := client.OAuth.Get(context.Background(), "consent_token")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", oauth.Data)
返回值:
client_id
(字符串类型),
logo_uri
(uri类型),
name
(字符串类型),
policy_uri
(uri类型),
redirect_uri
(uri类型),
requested_scopes
(对象数组类型),
tos_uri
(uri类型),
verified
(布尔类型)

Create OAuth grant

创建OAuth授权许可

Create an OAuth authorization grant
POST /oauth/grants
— Required:
allowed
,
consent_token
go
	response, err := client.OAuth.Grants(context.Background(), telnyx.OAuthGrantsParams{
		Allowed:      true,
		ConsentToken: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.example",
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.RedirectUri)
Returns:
redirect_uri
(uri)
创建OAuth授权许可
POST /oauth/grants
— 必填参数:
allowed
consent_token
go
	response, err := client.OAuth.Grants(context.Background(), telnyx.OAuthGrantsParams{
		Allowed:      true,
		ConsentToken: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.example",
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.RedirectUri)
返回值:
redirect_uri
(uri类型)

Token introspection

Token自省

Introspect an OAuth access token to check its validity and metadata
POST /oauth/introspect
— Required:
token
go
	response, err := client.OAuth.Introspect(context.Background(), telnyx.OAuthIntrospectParams{
		Token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.example",
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.ClientID)
Returns:
active
(boolean),
aud
(string),
client_id
(string),
exp
(integer),
iat
(integer),
iss
(string),
scope
(string)
校验OAuth访问令牌的有效性并获取其元数据
POST /oauth/introspect
— 必填参数:
token
go
	response, err := client.OAuth.Introspect(context.Background(), telnyx.OAuthIntrospectParams{
		Token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.example",
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.ClientID)
返回值:
active
(布尔类型),
aud
(字符串类型),
client_id
(字符串类型),
exp
(整数类型),
iat
(整数类型),
iss
(字符串类型),
scope
(字符串类型)

JSON Web Key Set

JSON Web Key Set

Retrieve the JSON Web Key Set for token verification
GET /oauth/jwks
go
	response, err := client.OAuth.GetJwks(context.Background())
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.Keys)
Returns:
keys
(array[object])
获取用于令牌校验的JSON Web Key Set
GET /oauth/jwks
go
	response, err := client.OAuth.GetJwks(context.Background())
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.Keys)
返回值:
keys
(对象数组类型)

Dynamic client registration

动态客户端注册

Register a new OAuth client dynamically (RFC 7591)
POST /oauth/register
Optional:
client_name
(string),
grant_types
(array[string]),
logo_uri
(uri),
policy_uri
(uri),
redirect_uris
(array[string]),
response_types
(array[string]),
scope
(string),
token_endpoint_auth_method
(enum: none, client_secret_basic, client_secret_post),
tos_uri
(uri)
go
	response, err := client.OAuth.Register(context.Background(), telnyx.OAuthRegisterParams{})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.ClientID)
Returns:
client_id
(string),
client_id_issued_at
(integer),
client_name
(string),
client_secret
(string),
grant_types
(array[string]),
logo_uri
(uri),
policy_uri
(uri),
redirect_uris
(array[string]),
response_types
(array[string]),
scope
(string),
token_endpoint_auth_method
(string),
tos_uri
(uri)
动态注册新的OAuth客户端(RFC 7591)
POST /oauth/register
可选参数:
client_name
(字符串类型),
grant_types
(字符串数组类型),
logo_uri
(uri类型),
policy_uri
(uri类型),
redirect_uris
(字符串数组类型),
response_types
(字符串数组类型),
scope
(字符串类型),
token_endpoint_auth_method
(枚举值:none, client_secret_basic, client_secret_post),
tos_uri
(uri类型)
go
	response, err := client.OAuth.Register(context.Background(), telnyx.OAuthRegisterParams{})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.ClientID)
返回值:
client_id
(字符串类型),
client_id_issued_at
(整数类型),
client_name
(字符串类型),
client_secret
(字符串类型),
grant_types
(字符串数组类型),
logo_uri
(uri类型),
policy_uri
(uri类型),
redirect_uris
(字符串数组类型),
response_types
(字符串数组类型),
scope
(字符串类型),
token_endpoint_auth_method
(字符串类型),
tos_uri
(uri类型)

OAuth token endpoint

OAuth令牌端点

Exchange authorization code, client credentials, or refresh token for access token
POST /oauth/token
— Required:
grant_type
Optional:
client_id
(string),
client_secret
(string),
code
(string),
code_verifier
(string),
redirect_uri
(uri),
refresh_token
(string),
scope
(string)
go
	response, err := client.OAuth.Token(context.Background(), telnyx.OAuthTokenParams{
		GrantType: telnyx.OAuthTokenParamsGrantTypeClientCredentials,
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.AccessToken)
Returns:
access_token
(string),
expires_in
(integer),
refresh_token
(string),
scope
(string),
token_type
(enum: Bearer)
使用授权码、客户端凭证或者刷新令牌兑换访问令牌
POST /oauth/token
— 必填参数:
grant_type
可选参数:
client_id
(字符串类型),
client_secret
(字符串类型),
code
(字符串类型),
code_verifier
(字符串类型),
redirect_uri
(uri类型),
refresh_token
(字符串类型),
scope
(字符串类型)
go
	response, err := client.OAuth.Token(context.Background(), telnyx.OAuthTokenParams{
		GrantType: telnyx.OAuthTokenParamsGrantTypeClientCredentials,
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.AccessToken)
返回值:
access_token
(字符串类型),
expires_in
(整数类型),
refresh_token
(字符串类型),
scope
(字符串类型),
token_type
(枚举值:Bearer)

List OAuth clients

列出OAuth客户端

Retrieve a paginated list of OAuth clients for the authenticated user
GET /oauth_clients
go
	page, err := client.OAuthClients.List(context.Background(), telnyx.OAuthClientListParams{})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", page)
Returns:
allowed_grant_types
(array[string]),
allowed_scopes
(array[string]),
client_id
(string),
client_secret
(string | null),
client_type
(enum: public, confidential),
created_at
(date-time),
logo_uri
(uri),
name
(string),
org_id
(string),
policy_uri
(uri),
record_type
(enum: oauth_client),
redirect_uris
(array[string]),
require_pkce
(boolean),
tos_uri
(uri),
updated_at
(date-time),
user_id
(string)
获取当前认证用户的OAuth客户端分页列表
GET /oauth_clients
go
	page, err := client.OAuthClients.List(context.Background(), telnyx.OAuthClientListParams{})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", page)
返回值:
allowed_grant_types
(字符串数组类型),
allowed_scopes
(字符串数组类型),
client_id
(字符串类型),
client_secret
(字符串/空类型),
client_type
(枚举值:public, confidential),
created_at
(日期时间类型),
logo_uri
(uri类型),
name
(字符串类型),
org_id
(字符串类型),
policy_uri
(uri类型),
record_type
(枚举值:oauth_client),
redirect_uris
(字符串数组类型),
require_pkce
(布尔类型),
tos_uri
(uri类型),
updated_at
(日期时间类型),
user_id
(字符串类型)

Create OAuth client

创建OAuth客户端

Create a new OAuth client
POST /oauth_clients
— Required:
name
,
allowed_scopes
,
client_type
,
allowed_grant_types
Optional:
logo_uri
(uri),
policy_uri
(uri),
redirect_uris
(array[string]),
require_pkce
(boolean),
tos_uri
(uri)
go
	oauthClient, err := client.OAuthClients.New(context.Background(), telnyx.OAuthClientNewParams{
		AllowedGrantTypes: []string{"client_credentials"},
		AllowedScopes:     []string{"admin"},
		ClientType:        telnyx.OAuthClientNewParamsClientTypePublic,
		Name:              "My OAuth client",
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", oauthClient.Data)
Returns:
allowed_grant_types
(array[string]),
allowed_scopes
(array[string]),
client_id
(string),
client_secret
(string | null),
client_type
(enum: public, confidential),
created_at
(date-time),
logo_uri
(uri),
name
(string),
org_id
(string),
policy_uri
(uri),
record_type
(enum: oauth_client),
redirect_uris
(array[string]),
require_pkce
(boolean),
tos_uri
(uri),
updated_at
(date-time),
user_id
(string)
创建新的OAuth客户端
POST /oauth_clients
— 必填参数:
name
allowed_scopes
client_type
allowed_grant_types
可选参数:
logo_uri
(uri类型),
policy_uri
(uri类型),
redirect_uris
(字符串数组类型),
require_pkce
(布尔类型),
tos_uri
(uri类型)
go
	oauthClient, err := client.OAuthClients.New(context.Background(), telnyx.OAuthClientNewParams{
		AllowedGrantTypes: []string{"client_credentials"},
		AllowedScopes:     []string{"admin"},
		ClientType:        telnyx.OAuthClientNewParamsClientTypePublic,
		Name:              "My OAuth client",
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", oauthClient.Data)
返回值:
allowed_grant_types
(字符串数组类型),
allowed_scopes
(字符串数组类型),
client_id
(字符串类型),
client_secret
(字符串/空类型),
client_type
(枚举值:public, confidential),
created_at
(日期时间类型),
logo_uri
(uri类型),
name
(字符串类型),
org_id
(字符串类型),
policy_uri
(uri类型),
record_type
(枚举值:oauth_client),
redirect_uris
(字符串数组类型),
require_pkce
(布尔类型),
tos_uri
(uri类型),
updated_at
(日期时间类型),
user_id
(字符串类型)

Get OAuth client

获取OAuth客户端

Retrieve a single OAuth client by ID
GET /oauth_clients/{id}
go
	oauthClient, err := client.OAuthClients.Get(context.Background(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", oauthClient.Data)
Returns:
allowed_grant_types
(array[string]),
allowed_scopes
(array[string]),
client_id
(string),
client_secret
(string | null),
client_type
(enum: public, confidential),
created_at
(date-time),
logo_uri
(uri),
name
(string),
org_id
(string),
policy_uri
(uri),
record_type
(enum: oauth_client),
redirect_uris
(array[string]),
require_pkce
(boolean),
tos_uri
(uri),
updated_at
(date-time),
user_id
(string)
根据ID获取单个OAuth客户端信息
GET /oauth_clients/{id}
go
	oauthClient, err := client.OAuthClients.Get(context.Background(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", oauthClient.Data)
返回值:
allowed_grant_types
(字符串数组类型),
allowed_scopes
(字符串数组类型),
client_id
(字符串类型),
client_secret
(字符串/空类型),
client_type
(枚举值:public, confidential),
created_at
(日期时间类型),
logo_uri
(uri类型),
name
(字符串类型),
org_id
(字符串类型),
policy_uri
(uri类型),
record_type
(枚举值:oauth_client),
redirect_uris
(字符串数组类型),
require_pkce
(布尔类型),
tos_uri
(uri类型),
updated_at
(日期时间类型),
user_id
(字符串类型)

Update OAuth client

更新OAuth客户端

Update an existing OAuth client
PUT /oauth_clients/{id}
Optional:
allowed_grant_types
(array[string]),
allowed_scopes
(array[string]),
logo_uri
(uri),
name
(string),
policy_uri
(uri),
redirect_uris
(array[string]),
require_pkce
(boolean),
tos_uri
(uri)
go
	oauthClient, err := client.OAuthClients.Update(
		context.Background(),
		"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
		telnyx.OAuthClientUpdateParams{},
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", oauthClient.Data)
Returns:
allowed_grant_types
(array[string]),
allowed_scopes
(array[string]),
client_id
(string),
client_secret
(string | null),
client_type
(enum: public, confidential),
created_at
(date-time),
logo_uri
(uri),
name
(string),
org_id
(string),
policy_uri
(uri),
record_type
(enum: oauth_client),
redirect_uris
(array[string]),
require_pkce
(boolean),
tos_uri
(uri),
updated_at
(date-time),
user_id
(string)
更新已有的OAuth客户端
PUT /oauth_clients/{id}
可选参数:
allowed_grant_types
(字符串数组类型),
allowed_scopes
(字符串数组类型),
logo_uri
(uri类型),
name
(字符串类型),
policy_uri
(uri类型),
redirect_uris
(字符串数组类型),
require_pkce
(布尔类型),
tos_uri
(uri类型)
go
	oauthClient, err := client.OAuthClients.Update(
		context.Background(),
		"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
		telnyx.OAuthClientUpdateParams{},
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", oauthClient.Data)
返回值:
allowed_grant_types
(字符串数组类型),
allowed_scopes
(字符串数组类型),
client_id
(字符串类型),
client_secret
(字符串/空类型),
client_type
(枚举值:public, confidential),
created_at
(日期时间类型),
logo_uri
(uri类型),
name
(字符串类型),
org_id
(字符串类型),
policy_uri
(uri类型),
record_type
(枚举值:oauth_client),
redirect_uris
(字符串数组类型),
require_pkce
(布尔类型),
tos_uri
(uri类型),
updated_at
(日期时间类型),
user_id
(字符串类型)

Delete OAuth client

删除OAuth客户端

Delete an OAuth client
DELETE /oauth_clients/{id}
go
	err := client.OAuthClients.Delete(context.Background(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
	if err != nil {
		log.Fatal(err)
	}
删除OAuth客户端
DELETE /oauth_clients/{id}
go
	err := client.OAuthClients.Delete(context.Background(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
	if err != nil {
		log.Fatal(err)
	}

List OAuth grants

列出OAuth授权许可

Retrieve a paginated list of OAuth grants for the authenticated user
GET /oauth_grants
go
	page, err := client.OAuthGrants.List(context.Background(), telnyx.OAuthGrantListParams{})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", page)
Returns:
client_id
(string),
created_at
(date-time),
id
(uuid),
last_used_at
(date-time),
record_type
(enum: oauth_grant),
scopes
(array[string])
获取当前认证用户的OAuth授权许可分页列表
GET /oauth_grants
go
	page, err := client.OAuthGrants.List(context.Background(), telnyx.OAuthGrantListParams{})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", page)
返回值:
client_id
(字符串类型),
created_at
(日期时间类型),
id
(uuid类型),
last_used_at
(日期时间类型),
record_type
(枚举值:oauth_grant),
scopes
(字符串数组类型)

Get OAuth grant

获取OAuth授权许可

Retrieve a single OAuth grant by ID
GET /oauth_grants/{id}
go
	oauthGrant, err := client.OAuthGrants.Get(context.Background(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", oauthGrant.Data)
Returns:
client_id
(string),
created_at
(date-time),
id
(uuid),
last_used_at
(date-time),
record_type
(enum: oauth_grant),
scopes
(array[string])
根据ID获取单个OAuth授权许可信息
GET /oauth_grants/{id}
go
	oauthGrant, err := client.OAuthGrants.Get(context.Background(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", oauthGrant.Data)
返回值:
client_id
(字符串类型),
created_at
(日期时间类型),
id
(uuid类型),
last_used_at
(日期时间类型),
record_type
(枚举值:oauth_grant),
scopes
(字符串数组类型)

Revoke OAuth grant

吊销OAuth授权许可

Revoke an OAuth grant
DELETE /oauth_grants/{id}
go
	oauthGrant, err := client.OAuthGrants.Delete(context.Background(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", oauthGrant.Data)
Returns:
client_id
(string),
created_at
(date-time),
id
(uuid),
last_used_at
(date-time),
record_type
(enum: oauth_grant),
scopes
(array[string])
吊销OAuth授权许可
DELETE /oauth_grants/{id}
go
	oauthGrant, err := client.OAuthGrants.Delete(context.Background(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", oauthGrant.Data)
返回值:
client_id
(字符串类型),
created_at
(日期时间类型),
id
(uuid类型),
last_used_at
(日期时间类型),
record_type
(枚举值:oauth_grant),
scopes
(字符串数组类型)