I have a JWT token, and I'm trying to decode the payload. The string I'm trying to decode is:
eyJzdWIiOiIyMzEzOTE6MTAxMjpFQiBBZG1pbixFQiBDaGVjayBJbi9PdXQgUmVzb3VyY2VzLEVCIE1hc3RlciBBZG1pbiIsImV4cCI6IjE1NDUyNTc2MDkiLCJhdWQiOiI0OTk0QzgxMC02QUMyLTQ3NkYtQjUyQi04MjQ5NUUzRUNBNTgifQ
If I go to https://www.base64decode.org/ and plug in that string, it decodes just fine to:
{"sub":"231391:1012:EB Admin,EB Check In/Out Resources,EB Master Admin","exp":"1545257466","aud":"4994C810-6AC2-476F-B52B-82495E3ECA58"}
But with this:
byte[] dataPayload = Convert.FromBase64String(tokenPayload);
I get:
Invalid length for a Base-64 char array or string
Not sure what I am doing wrong.
EDIT:
This is the entire JWT, as delivered by JWT.IO (i added line breaks so it's easier to read)...
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9. eyJzdWIiOiIyMzEzOTE6MTAxMjpFQiBBZG1pbixFQiBDaGVjayBJbi9PdXQgUmVzb3VyY2VzLEVCIE1hc3RlciBBZG1pbiIsImV4cCI6IjE1NDUyNTc4ODMiLCJhdWQiOiI0OTk0QzgxMC02QUMyLTQ3NkYtQjUyQi04MjQ5NUUzRUNBNTgifQ. 0oaXmDOlYdHSTLo7t7fFpHG2T0DMRpAoERxiM_Ur5O4
This same two line of code have been working fine:
string tokenPayload = _jwtData.WebToken.Split('.')[1];
byte[] dataPayload = Convert.FromBase64String(tokenPayload);
But for some reason that I don't understand, now I am getting this error.