-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JWT Token Header #231
Comments
Hi @wicetram , is it what you looking for https://github.com/dvsekhvalnov/jose-jwt#adding-extra-headers ? Just pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
I need to encrypt Payload data with a JWK string. I can encrypt using the Nuget package, but I have a problem with the header part of the encrypted JWT data. The required header content should only contain the values "alg" and "kid". However, in all the ways I tried, this header part (at least in C#) always comes with the values "alg" and "typ".
When I encrypt this JWK and Payload data with the Java code I use as an example, I can successfully produce JWT information.
I need your help on this matter. Thanks.
C# JWT Header:
{
"alg": "HS256",
"typ": "JWT"
}
Java JWT Header:
{
"alg": "HS256",
"kid": "7b76e130-73de-4562-9c20-ad5e983e22d8"
}
Java:
package org.example;
import com.nimbusds.jose.*;
import com.nimbusds.jose.crypto.MACSigner;
import com.nimbusds.jose.jwk.JWK;
import okhttp3.*;
import java.io.IOException;
import java.text.ParseException;
public class Main {
public static void main(String[] args) throws ParseException, JOSEException, IOException {
String payload = "{"meta": {"id": "168bba80-5e69-485e-8d16-2e9750cb9c2e","clientInfo": [{"type": "serverIp","value": "WEB"}]},"data": {"orderId": "","amount": 2,"operation": "sales","returnUrl": {"link": "https://","type": "web"},"customer": {"nationalNumber": "","gsmNumber": ""},"paymentOptions": {"threeDSecureCheck": true,"installmentOnlyForCommercialCard": true}}}";
}
C#:
using Jose;
using Newtonsoft.Json;
using System.Text;
class Program
{
static void Main()
{
var jwtRequest = new TokenRequestDto
{
Kid = "28075256-56c8-11ee-8c99-0242ac120002",
K = "eSvOcX4/NrjfRsShI+KgHw==",
Alg = "HS256"
};
}
The text was updated successfully, but these errors were encountered: