CyberSource / CyberSource/cybersource-rest-samples-csharp

Sample code for generating jwtBody not working well

Open
#75 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
28
Forks
46
PR merge metrics
No merged PRs in 30d

Description

https://github.com/CyberSource/cybersource-rest-samples-csharp/blob/63e9781946ceb7b303457d950e99f4fbea5f2568/Source/Samples/Authentication/StandAloneJWT.cs#L174

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.