Create OAuth client
Creates a new OAuth client on your account for authenticating third-party integrations, and returns the created client.
POST
/
oauth
/
clients
JavaScript
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const oauthClient = await client.oauthClients.create({
allowed_grant_types: ['client_credentials'],
allowed_scopes: ['admin'],
client_type: 'public',
name: 'My OAuth client',
});
console.log(oauthClient.data);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
oauth_client = client.oauth_clients.create(
allowed_grant_types=["client_credentials"],
allowed_scopes=["admin"],
client_type="public",
name="My OAuth client",
)
print(oauth_client.data)package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
oauthClient, err := client.OAuthClients.New(context.TODO(), telnyx.OAuthClientNewParams{
AllowedGrantTypes: []string{"client_credentials"},
AllowedScopes: []string{"admin"},
ClientType: telnyx.OAuthClientNewParamsClientTypePublic,
Name: "My OAuth client",
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", oauthClient.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.oauthclients.OAuthClientCreateParams;
import com.telnyx.sdk.models.oauthclients.OAuthClientCreateResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
OAuthClientCreateParams params = OAuthClientCreateParams.builder()
.addAllowedGrantType(OAuthClientCreateParams.AllowedGrantType.CLIENT_CREDENTIALS)
.addAllowedScope("admin")
.clientType(OAuthClientCreateParams.ClientType.PUBLIC)
.name("My OAuth client")
.build();
OAuthClientCreateResponse oauthClient = client.oauthClients().create(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
oauth_client = telnyx.oauth_clients.create(
allowed_grant_types: [:client_credentials],
allowed_scopes: ["admin"],
client_type: :public,
name: "My OAuth client"
)
puts(oauth_client)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$oauthClient = $client->oauthClients->create(
allowedGrantTypes: ['client_credentials'],
allowedScopes: ['admin'],
clientType: 'public',
name: 'My OAuth client',
logoUri: 'https://example.com',
policyUri: 'https://example.com',
redirectUris: ['https://example.com'],
requirePkce: true,
tosUri: 'https://example.com',
);
var_dump($oauthClient);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx oauth-clients create \
--api-key 'My API Key' \
--allowed-grant-type client_credentials \
--allowed-scope admin \
--client-type public \
--name 'My OAuth client'curl --request POST \
--url https://api.telnyx.com/v2/oauth/clients \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "My OAuth client",
"allowed_scopes": [
"admin"
],
"allowed_grant_types": [],
"require_pkce": false,
"redirect_uris": [],
"logo_uri": "<string>",
"policy_uri": "<string>",
"tos_uri": "<string>"
}
'{
"data": {
"record_type": "oauth_client",
"client_id": "string",
"name": "string",
"org_id": "string",
"user_id": "string",
"allowed_scopes": [
"string"
],
"client_type": "public",
"require_pkce": false,
"allowed_grant_types": [
"client_credentials"
],
"redirect_uris": [
"https://example.com"
],
"created_at": "2024-01-23T18:10:02.574Z",
"updated_at": "2024-01-23T18:10:02.574Z"
}
}{
"error": "<string>",
"error_description": "<string>"
}{
"error": "<string>",
"error_description": "<string>"
}{
"error": "<string>",
"error_description": "<string>"
}Authorizations
Body
application/json
Was this page helpful?
JavaScript
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const oauthClient = await client.oauthClients.create({
allowed_grant_types: ['client_credentials'],
allowed_scopes: ['admin'],
client_type: 'public',
name: 'My OAuth client',
});
console.log(oauthClient.data);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
oauth_client = client.oauth_clients.create(
allowed_grant_types=["client_credentials"],
allowed_scopes=["admin"],
client_type="public",
name="My OAuth client",
)
print(oauth_client.data)package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
oauthClient, err := client.OAuthClients.New(context.TODO(), telnyx.OAuthClientNewParams{
AllowedGrantTypes: []string{"client_credentials"},
AllowedScopes: []string{"admin"},
ClientType: telnyx.OAuthClientNewParamsClientTypePublic,
Name: "My OAuth client",
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", oauthClient.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.oauthclients.OAuthClientCreateParams;
import com.telnyx.sdk.models.oauthclients.OAuthClientCreateResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
OAuthClientCreateParams params = OAuthClientCreateParams.builder()
.addAllowedGrantType(OAuthClientCreateParams.AllowedGrantType.CLIENT_CREDENTIALS)
.addAllowedScope("admin")
.clientType(OAuthClientCreateParams.ClientType.PUBLIC)
.name("My OAuth client")
.build();
OAuthClientCreateResponse oauthClient = client.oauthClients().create(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
oauth_client = telnyx.oauth_clients.create(
allowed_grant_types: [:client_credentials],
allowed_scopes: ["admin"],
client_type: :public,
name: "My OAuth client"
)
puts(oauth_client)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$oauthClient = $client->oauthClients->create(
allowedGrantTypes: ['client_credentials'],
allowedScopes: ['admin'],
clientType: 'public',
name: 'My OAuth client',
logoUri: 'https://example.com',
policyUri: 'https://example.com',
redirectUris: ['https://example.com'],
requirePkce: true,
tosUri: 'https://example.com',
);
var_dump($oauthClient);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx oauth-clients create \
--api-key 'My API Key' \
--allowed-grant-type client_credentials \
--allowed-scope admin \
--client-type public \
--name 'My OAuth client'curl --request POST \
--url https://api.telnyx.com/v2/oauth/clients \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "My OAuth client",
"allowed_scopes": [
"admin"
],
"allowed_grant_types": [],
"require_pkce": false,
"redirect_uris": [],
"logo_uri": "<string>",
"policy_uri": "<string>",
"tos_uri": "<string>"
}
'{
"data": {
"record_type": "oauth_client",
"client_id": "string",
"name": "string",
"org_id": "string",
"user_id": "string",
"allowed_scopes": [
"string"
],
"client_type": "public",
"require_pkce": false,
"allowed_grant_types": [
"client_credentials"
],
"redirect_uris": [
"https://example.com"
],
"created_at": "2024-01-23T18:10:02.574Z",
"updated_at": "2024-01-23T18:10:02.574Z"
}
}{
"error": "<string>",
"error_description": "<string>"
}{
"error": "<string>",
"error_description": "<string>"
}{
"error": "<string>",
"error_description": "<string>"
}