Create OAuth client
Create a new OAuth 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>",
"require_pkce": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"allowed_scopes": [
"<string>"
],
"allowed_grant_types": [],
"redirect_uris": [
"<string>"
],
"logo_uri": "<string>",
"tos_uri": "<string>",
"policy_uri": "<string>",
"client_secret": "<string>"
}
}{
"error": "<string>",
"error_description": "<string>"
}{
"error": "<string>",
"error_description": "<string>"
}{
"error": "<string>",
"error_description": "<string>"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
The name of the OAuth client
Example:
"My OAuth client"
List of allowed OAuth scopes
Example:
["admin"]OAuth client type
Available options:
public, confidential List of allowed OAuth grant types
Available options:
client_credentials, authorization_code, refresh_token Whether PKCE (Proof Key for Code Exchange) is required for this client
List of redirect URIs (required for authorization_code flow)
URL of the client logo
URL of the client's privacy policy
URL of the client's terms of service
Response
OAuth client created successfully
Show child attributes
Show child attributes
Was this page helpful?
⌘I
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>",
"require_pkce": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"allowed_scopes": [
"<string>"
],
"allowed_grant_types": [],
"redirect_uris": [
"<string>"
],
"logo_uri": "<string>",
"tos_uri": "<string>",
"policy_uri": "<string>",
"client_secret": "<string>"
}
}{
"error": "<string>",
"error_description": "<string>"
}{
"error": "<string>",
"error_description": "<string>"
}{
"error": "<string>",
"error_description": "<string>"
}