Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

"Could not match JWT signature to any of the bindings" error meaning when getting access token?

BenCrowe
Level 1
Level 1

I have an app that uses the Privacy API to anonymise user details upon request. The app generates a JWT and sends it to https://ims-na1.adobelogin.com/ims/exchange/jwt to retrieve an access token to use for the Privacy API request. However, following the recent changes to the Adobe I/O console, my app has stopped working. In an effort to get it working again, I have created a new project in the console to use for it. Now when trying to get an access token, I am getting a 400 bad request error with the detail of "Could not match JWT signature to any of the bindings". Can anyone please tell me exactly what causes this specific error? I can't find it mentioned in the documentation.

1 Accepted Solution
BenCrowe
Correct answer by
Level 1
Level 1

I've found the answer myself; I was using the incorrect private key.

View solution in original post

7 Replies
BenCrowe
Correct answer by
Level 1
Level 1

I've found the answer myself; I was using the incorrect private key.

View solution in original post

BenCrowe
Level 1
Level 1
Hi JohnnyBravo, which part are you struggling with? And what language are you using?
JohnnyBravo
Level 2
Level 2

Hi BenCrowe, I'm trying to create an app to do the same thing; generate a JWT to get an access token. Could you do me a massive favor and share your code with me? I'm struggling to get my app to work. Much appreciated if possible! Thank you

JohnnyBravo
Level 2
Level 2

Hi BenCrowe, thank you very much for the reply. I'm using C# / console app, and I keep getting the same error you got "Could not match JWT signature to any of the bindings" when I try to get the access token after generating the JWT per the below and posting. I'm certain I have the right key. Below is what I have. Thanks again for any tips, much appreciated!

 

using Microsoft.IdentityModel.Tokens;
using RestSharp;
using System;

using System.IdentityModel.Tokens.Jwt;

using System.Linq;

using System.Text

string key = System.IO.File.ReadAllText(@"C:\[directory....]\private.key");

var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(key));

var credentials = new SigningCredentials
(securityKey, SecurityAlgorithms.HmacSha256Signature);

var header = new JwtHeader(credentials);

var payload = new JwtPayload
{  // payload stuff - double checked - values correct
{"exp",'....''},
{ "iss",",,,,,,"},
{"sub","......."},
{"https://.........",true},
{"aud","......."}
};

var secToken = new JwtSecurityToken(header, payload);
var handler = new JwtSecurityTokenHandler();

var tokenString = handler.WriteToken(secToken);

Console.WriteLine(tokenString);
Console.WriteLine("Consume Token");

var token = handler.ReadJwtToken(tokenString);

Console.WriteLine(token.Payload.First().Value);

BenCrowe
Level 1
Level 1

Hi JohnnyBravo, I'm afraid I don't know C#. The code I wrote is in PHP for a Linux-based server. All I can suggest is outputting the key data you are reading in somewhere, a debug log or something, to make sure you are reading it correctly. I would also maybe avoid applying the UTF8 coding to the key to see if that helps, it may be changing the value somehow.

JohnnyBravo
Level 2
Level 2
Thank you for the reply BenCrowe. I'm using C#. I'm getting the same error you mentioned you got before "Could not match JWT signature to any of the bindings" when trying to retrieve the access token. I'm sure I'm using the correct private key. How did you put the key into your code? I'm using System.IO and reading the key from a folder on C: drive. Thanks again
JohnnyBravo
Level 2
Level 2
Thank you BenCrowe. I really appreciate your replies and help. I'll try the tips you recommended and see if that does the trick. Thanks again, take care.