How to decode JWT (Header and Body) in java using Apache Commons Codec?

Here you go: import org.apache.commons.codec.binary.Base64; @Test public void testDecodeJWT(){ String jwtToken = “eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0Iiwicm9sZXMiOiJST0xFX0FETUlOIiwiaXNzIjoibXlzZWxmIiwiZXhwIjoxNDcxMDg2MzgxfQ.1EI2haSz9aMsHjFUXNVz2Z4mtC0nMdZo6bo3-x-aRpw”; System.out.println(“———— Decode JWT ————“); String[] split_string = jwtToken.split(“\\.”); String base64EncodedHeader = split_string[0]; String base64EncodedBody = split_string[1]; String base64EncodedSignature = split_string[2]; System.out.println(“~~~~~~~~~ JWT Header ~~~~~~~”); Base64 base64Url = new Base64(true); String header = new String(base64Url.decode(base64EncodedHeader)); System.out.println(“JWT Header : ” + header); System.out.println(“~~~~~~~~~ JWT … Read more

Apache Commons Codec with Android: could not find method

I had a similar problem while using android with an OAuth library I’m developing. I also got from android that, although I had included apache.commons.codec in the classpath, a particular method (encodeBase64String) was not found. Checking the javadocs, both methods claim to be 1.4 and greater only, so my guess is that android already includes … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)