applicationId uz neni povinne
This commit is contained in:
@@ -10,6 +10,13 @@ public sealed record IdokladCredentials
|
||||
{
|
||||
public required string ClientId { get; init; }
|
||||
public required string ClientSecret { get; init; }
|
||||
public required string ApplicationId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Optional iDoklad ApplicationId (GUID from the developer portal). Only needed for partner
|
||||
/// applications whose client_credentials grant requires application_id. When empty, the
|
||||
/// service authenticates with client_id + client_secret only.
|
||||
/// </summary>
|
||||
public string? ApplicationId { get; init; }
|
||||
|
||||
public required Language Language { get; init; }
|
||||
}
|
||||
|
||||
@@ -28,12 +28,12 @@ public sealed class RequestCredentialsProvider
|
||||
|
||||
var clientId = HeaderOrDefault(headers, CredentialConstants.ClientIdHeader, _settings.ClientId);
|
||||
var clientSecret = HeaderOrDefault(headers, CredentialConstants.ClientSecretHeader, _settings.ClientSecret);
|
||||
// ApplicationId is optional: iDoklad's standard client_credentials grant does not require it.
|
||||
var applicationId = HeaderOrDefault(headers, CredentialConstants.ApplicationIdHeader, _settings.ApplicationId);
|
||||
|
||||
var missing = new List<string>();
|
||||
if (string.IsNullOrWhiteSpace(clientId)) missing.Add(CredentialConstants.ClientIdHeader);
|
||||
if (string.IsNullOrWhiteSpace(clientSecret)) missing.Add(CredentialConstants.ClientSecretHeader);
|
||||
if (string.IsNullOrWhiteSpace(applicationId)) missing.Add(CredentialConstants.ApplicationIdHeader);
|
||||
if (missing.Count > 0)
|
||||
{
|
||||
throw new MissingCredentialsException(missing);
|
||||
@@ -43,7 +43,7 @@ public sealed class RequestCredentialsProvider
|
||||
{
|
||||
ClientId = clientId!,
|
||||
ClientSecret = clientSecret!,
|
||||
ApplicationId = applicationId!,
|
||||
ApplicationId = string.IsNullOrWhiteSpace(applicationId) ? null : applicationId,
|
||||
Language = ResolveLanguage(headers),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user