Skip to content

Commit

Permalink
fix Token Reqeust
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Tuerk <[email protected]>
  • Loading branch information
Johannes Tuerk committed Dec 22, 2023
1 parent 10789a5 commit dd9784f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public class TokenRequest
/// <summary>
/// Gets or sets the user PIN. This value must be present if a PIN was required in a previous step.
/// </summary>
[JsonProperty("user_pin")]
public string? UserPin { get; set; }
[JsonProperty("tx_code")]
public string? TransactionCode { get; set; }

/// <summary>
/// Converts the properties of the TokenRequest instance into an FormUrlEncodedContent type suitable for HTTP POST
Expand All @@ -54,8 +54,8 @@ public FormUrlEncodedContent ToFormUrlEncoded()
if (!string.IsNullOrEmpty(Scope))
keyValuePairs.Add(new KeyValuePair<string, string>("scope", Scope));

if (!string.IsNullOrEmpty(UserPin))
keyValuePairs.Add(new KeyValuePair<string, string>("user_pin", UserPin));
if (!string.IsNullOrEmpty(TransactionCode))
keyValuePairs.Add(new KeyValuePair<string, string>("tx_code", TransactionCode));

return new FormUrlEncodedContent(keyValuePairs);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public virtual async Task<OidIssuerMetadata> FetchIssuerMetadataAsync(Uri endpoi

/// <inheritdoc />
public virtual async Task<TokenResponse> RequestTokenAsync(OidIssuerMetadata metadata, string preAuthorizedCode,
string? pin = null)
string? transactionCode = null)
{
var authServer = await GetAuthorizationServerMetadata(metadata);

Expand All @@ -120,9 +120,9 @@ public virtual async Task<TokenResponse> RequestTokenAsync(OidIssuerMetadata met
PreAuthorizedCode = preAuthorizedCode
};

if (!string.IsNullOrEmpty(pin))
if (!string.IsNullOrEmpty(transactionCode))
{
tokenRequest.UserPin = pin;
tokenRequest.TransactionCode = transactionCode;
}

var formUrlEncodedRequest = tokenRequest.ToFormUrlEncoded();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public interface IOid4VciClientService
/// </summary>
/// <param name="metadata">The OID issuer metadata.</param>
/// <param name="preAuthorizedCode">The pre-authorized code for token request.</param>
/// <param name="pin">The PIN.</param>
/// <param name="transactionCode">The Transaction Code.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains the token response.</returns>
Task<TokenResponse> RequestTokenAsync(OidIssuerMetadata metadata, string preAuthorizedCode, string? pin = null);
Task<TokenResponse> RequestTokenAsync(OidIssuerMetadata metadata, string preAuthorizedCode, string? transactionCode = null);
}
}

0 comments on commit dd9784f

Please sign in to comment.