CyberSource / CyberSource/cybersource-rest-samples-csharp
Sample code for generating jwtBody not working well
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 28
- Forks
- 46
- PR merge metrics
- No merged PRs in 30d
Description
As you see in line 174, the code was performed manual JSON creation so when submitting the code to CYBS, it threw a bad_request error and I spend around half-day to identifying what is going wrong.
After that, I've found that the code block should be:
var obj = new
{
digest = digest,
digestAlgorithm = "SHA-256",
iat = DateTime.Now.ToUniversalTime().ToString("r")
};
jwtBody = JsonConvert.SerializeObject(obj);
Because when you perform the code by using manual JSON, it was not correct when generating the JWT token, and it always thrown bad_request. After I changed it to above code block, it's working normally.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open Source/Samples/Authentication/StandAloneJWT.cs at line 174 and inspect how jwtBody is assembled. Replace the faulty manual JSON construction with the serialization approach shown in the issue, then verify that the generated JWT submission no longer returns a bad_request error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100