Reputation: 21
I am working with Microsoft's Verifiable Credentials sample: https://github.com/Azure-Samples/active-directory-verifiable-credentials-dotnet/tree/main/1-asp-net-core-api-idtokenhint
Rather than use fixed contact values as per the test (see IssuerController.cs), I want to use query params from a form I have added to the Index page (e.g. an input called "firstname"). I can see the params in the results page URL, however I cannot find a way to set these correctly.
I've tried a few methods in IssuerController.cs. First by amending the static value to a query request:
payload["issuance"]["claims"]["given_name"] = HttpContext.Request.Query["firstname"].ToString();
I've also tried setting a property:
[FromQuery(Name = "firstname")]
public string firstname { get; set; }
And then adding the property to the payload:
payload["issuance"]["claims"]["given_name"] = firstname;
Sadly all of this results in the same error:
"Missing provided claims in issuance: [given_name]","target":"issuance.claims"
For reference, the method signature is
public async Task<ActionResult> IssuanceRequest()
As you may gather, I am not savvy with .NET.
What is the correct way to do this please? Thanks
Upvotes: 2
Views: 559
Reputation: 1
If I understand correctly, you just can add a parameter to you action method like this:
public async Task<ActionResult> IssuanceRequest(string firstname)
Or add a FromQuery attribute if you want to specify a source of a value, and name of query parameter (optional):
public async Task<ActionResult> IssuanceRequest([FromQuery(Name = "firstname"]string firstname)
Upvotes: 0
Reputation: 21
Right, I'm sure there are other ways to do this but we got it working in the end by amending the IssuanceRequest method in Issuer.cshtml
fetch('/api/issuer/[email protected]["firstName"].ToString()&[email protected]["lastName"].ToString()&[email protected]["email"].ToString()&[email protected]["phone"].ToString()')
Thanks for the help anyway
Upvotes: 0