Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
543 changes: 543 additions & 0 deletions reference.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Auth0.ManagementApi/Auth0.ManagementApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>12</LangVersion>
<Nullable>enable</Nullable>
<Version>7.44.0</Version>
<Version>7.45.1</Version>
<AssemblyVersion>$(Version)</AssemblyVersion>
<FileVersion>$(Version)</FileVersion>
<PackageReadmeFile>README.md</PackageReadmeFile>
Expand Down
224 changes: 224 additions & 0 deletions src/Auth0.ManagementApi/Clients/ClientsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,188 @@ private async Task<WithRawResponse<CreateClientResponseContent>> CreateAsyncCore
}
}

private async Task<
WithRawResponse<PreviewCimdMetadataResponseContent>
> PreviewCimdMetadataAsyncCore(
PreviewCimdMetadataRequestContent request,
RequestOptions? options = null,
CancellationToken cancellationToken = default
)
{
var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder()
.Add(_client.Options.Headers)
.Add(_client.Options.AdditionalHeaders)
.Add(options?.AdditionalHeaders)
.BuildAsync()
.ConfigureAwait(false);
var response = await _client
.SendRequestAsync(
new JsonRequest
{
Method = HttpMethod.Post,
Path = "clients/cimd/preview",
Body = request,
Headers = _headers,
ContentType = "application/json",
Options = options,
},
cancellationToken
)
.ConfigureAwait(false);
if (response.StatusCode is >= 200 and < 400)
{
var responseBody = await response
.Raw.Content.ReadAsStringAsync(cancellationToken)
.ConfigureAwait(false);
try
{
var responseData = JsonUtils.Deserialize<PreviewCimdMetadataResponseContent>(
responseBody
)!;
return new WithRawResponse<PreviewCimdMetadataResponseContent>()
{
Data = responseData,
RawResponse = new RawResponse()
{
StatusCode = response.Raw.StatusCode,
Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"),
Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw),
},
};
}
catch (JsonException e)
{
throw new ManagementApiException(
"Failed to deserialize response",
response.StatusCode,
null,
e
);
}
}
{
var responseBody = await response
.Raw.Content.ReadAsStringAsync(cancellationToken)
.ConfigureAwait(false);
try
{
switch (response.StatusCode)
{
case 400:
throw new BadRequestError(JsonUtils.Deserialize<object>(responseBody));
case 401:
throw new UnauthorizedError(JsonUtils.Deserialize<object>(responseBody));
case 403:
throw new ForbiddenError(JsonUtils.Deserialize<object>(responseBody));
case 429:
throw new TooManyRequestsError(JsonUtils.Deserialize<object>(responseBody));
case 500:
throw new InternalServerError(JsonUtils.Deserialize<object>(responseBody));
}
}
catch (JsonException)
{
// unable to map error response, throwing generic error
}
throw new ManagementApiException(
$"Error with status code {response.StatusCode}",
response.StatusCode,
responseBody
);
}
}

private async Task<
WithRawResponse<RegisterCimdClientResponseContent>
> RegisterCimdClientAsyncCore(
RegisterCimdClientRequestContent request,
RequestOptions? options = null,
CancellationToken cancellationToken = default
)
{
var _headers = await new Auth0.ManagementApi.Core.HeadersBuilder.Builder()
.Add(_client.Options.Headers)
.Add(_client.Options.AdditionalHeaders)
.Add(options?.AdditionalHeaders)
.BuildAsync()
.ConfigureAwait(false);
var response = await _client
.SendRequestAsync(
new JsonRequest
{
Method = HttpMethod.Post,
Path = "clients/cimd/register",
Body = request,
Headers = _headers,
ContentType = "application/json",
Options = options,
},
cancellationToken
)
.ConfigureAwait(false);
if (response.StatusCode is >= 200 and < 400)
{
var responseBody = await response
.Raw.Content.ReadAsStringAsync(cancellationToken)
.ConfigureAwait(false);
try
{
var responseData = JsonUtils.Deserialize<RegisterCimdClientResponseContent>(
responseBody
)!;
return new WithRawResponse<RegisterCimdClientResponseContent>()
{
Data = responseData,
RawResponse = new RawResponse()
{
StatusCode = response.Raw.StatusCode,
Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"),
Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw),
},
};
}
catch (JsonException e)
{
throw new ManagementApiException(
"Failed to deserialize response",
response.StatusCode,
null,
e
);
}
}
{
var responseBody = await response
.Raw.Content.ReadAsStringAsync(cancellationToken)
.ConfigureAwait(false);
try
{
switch (response.StatusCode)
{
case 400:
throw new BadRequestError(JsonUtils.Deserialize<object>(responseBody));
case 401:
throw new UnauthorizedError(JsonUtils.Deserialize<object>(responseBody));
case 403:
throw new ForbiddenError(JsonUtils.Deserialize<object>(responseBody));
case 429:
throw new TooManyRequestsError(JsonUtils.Deserialize<object>(responseBody));
case 500:
throw new InternalServerError(JsonUtils.Deserialize<object>(responseBody));
}
}
catch (JsonException)
{
// unable to map error response, throwing generic error
}
throw new ManagementApiException(
$"Error with status code {response.StatusCode}",
response.StatusCode,
responseBody
);
}
}

private async Task<WithRawResponse<GetClientResponseContent>> GetAsyncCore(
string id,
GetClientRequestParameters request,
Expand Down Expand Up @@ -658,6 +840,48 @@ public WithRawResponseTask<CreateClientResponseContent> CreateAsync(
);
}

/// <summary>
/// Fetches and validates a Client ID Metadata Document without creating a client.
/// Returns the raw metadata and how it would be mapped to Auth0 client fields.
/// This endpoint is useful for testing metadata URIs before creating CIMD clients.
/// </summary>
/// <example><code>
/// await client.Clients.PreviewCimdMetadataAsync(
/// new PreviewCimdMetadataRequestContent { ExternalClientId = "external_client_id" }
/// );
/// </code></example>
public WithRawResponseTask<PreviewCimdMetadataResponseContent> PreviewCimdMetadataAsync(
PreviewCimdMetadataRequestContent request,
RequestOptions? options = null,
CancellationToken cancellationToken = default
)
{
return new WithRawResponseTask<PreviewCimdMetadataResponseContent>(
PreviewCimdMetadataAsyncCore(request, options, cancellationToken)
);
}

/// <summary>
/// Idempotent registration for Client ID Metadata Document (CIMD) clients.
/// Uses external_client_id as the unique identifier for upsert operations.
/// **Create:** Returns 201 when a new client is created (requires \
/// </summary>
/// <example><code>
/// await client.Clients.RegisterCimdClientAsync(
/// new RegisterCimdClientRequestContent { ExternalClientId = "external_client_id" }
/// );
/// </code></example>
public WithRawResponseTask<RegisterCimdClientResponseContent> RegisterCimdClientAsync(
RegisterCimdClientRequestContent request,
RequestOptions? options = null,
CancellationToken cancellationToken = default
)
{
return new WithRawResponseTask<RegisterCimdClientResponseContent>(
RegisterCimdClientAsyncCore(request, options, cancellationToken)
);
}

/// <summary>
/// Retrieve client details by ID. Clients are SSO connections or Applications linked with your Auth0 tenant. A list of fields to include or exclude may also be specified.
/// For more information, read <see href="https://www.auth0.com/docs/get-started/applications"> Applications in Auth0</see> and <see href="https://www.auth0.com/docs/authenticate/single-sign-on"> Single Sign-On</see>.
Expand Down
22 changes: 22 additions & 0 deletions src/Auth0.ManagementApi/Clients/IClientsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,28 @@ WithRawResponseTask<CreateClientResponseContent> CreateAsync(
CancellationToken cancellationToken = default
);

/// <summary>
/// Fetches and validates a Client ID Metadata Document without creating a client.
/// Returns the raw metadata and how it would be mapped to Auth0 client fields.
/// This endpoint is useful for testing metadata URIs before creating CIMD clients.
/// </summary>
WithRawResponseTask<PreviewCimdMetadataResponseContent> PreviewCimdMetadataAsync(
PreviewCimdMetadataRequestContent request,
RequestOptions? options = null,
CancellationToken cancellationToken = default
);

/// <summary>
/// Idempotent registration for Client ID Metadata Document (CIMD) clients.
/// Uses external_client_id as the unique identifier for upsert operations.
/// **Create:** Returns 201 when a new client is created (requires \
/// </summary>
WithRawResponseTask<RegisterCimdClientResponseContent> RegisterCimdClientAsync(
RegisterCimdClientRequestContent request,
RequestOptions? options = null,
CancellationToken cancellationToken = default
);

/// <summary>
/// Retrieve client details by ID. Clients are SSO connections or Applications linked with your Auth0 tenant. A list of fields to include or exclude may also be specified.
/// For more information, read <see href="https://www.auth0.com/docs/get-started/applications"> Applications in Auth0</see> and <see href="https://www.auth0.com/docs/authenticate/single-sign-on"> Single Sign-On</see>.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Auth0.ManagementApi.Core;
using global::System.Text.Json.Serialization;

namespace Auth0.ManagementApi;

[Serializable]
public record PreviewCimdMetadataRequestContent
{
/// <summary>
/// URL to the Client ID Metadata Document
/// </summary>
[JsonPropertyName("external_client_id")]
public required string ExternalClientId { get; set; }

/// <inheritdoc />
public override string ToString()
{
return JsonUtils.Serialize(this);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Auth0.ManagementApi.Core;
using global::System.Text.Json.Serialization;

namespace Auth0.ManagementApi;

[Serializable]
public record RegisterCimdClientRequestContent
{
/// <summary>
/// URL to the Client ID Metadata Document. Acts as the unique identifier for upsert operations.
/// </summary>
[JsonPropertyName("external_client_id")]
public required string ExternalClientId { get; set; }

/// <inheritdoc />
public override string ToString()
{
return JsonUtils.Serialize(this);
}
}
2 changes: 1 addition & 1 deletion src/Auth0.ManagementApi/Core/Public/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ namespace Auth0.ManagementApi;
[Serializable]
internal class Version
{
public const string Current = "7.44.0";
public const string Current = "7.45.1";
}
16 changes: 0 additions & 16 deletions src/Auth0.ManagementApi/CustomDomainHeader.cs

This file was deleted.

Loading
Loading