# Eorror decoding token "The token was expected to have 3 parts, but got 5"

**URL:** <https://community.auth0.com/t/eorror-decoding-token-the-token-was-expected-to-have-3-parts-but-got-5/59558>\
**Category:** Get Help\
**Tags:** jwt, decrypt, auth0\
**Created:** [March 17, 2021, 12:38am UTC](https://community.auth0.com/t/eorror-decoding-token-the-token-was-expected-to-have-3-parts-but-got-5/59558 "2021-03-17T00:38:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tattwadarsi.biswal](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/tattwadarsi.biswal/32/28224_2.png) [@tattwadarsi.biswal](https://community.auth0.com/u/tattwadarsi.biswal)\
**Post date:** [March 17, 2021, 12:38am UTC](https://community.auth0.com/t/eorror-decoding-token-the-token-was-expected-to-have-3-parts-but-got-5/59558/1 "2021-03-17T00:38:23Z")

</div>

Getting error while trying to verify JWE (JWT with EC encrypted)  
Doest auth0 support JWE ?

I am using com.auth0:java-jwt version 3.14.0

JWE header details  
{  
“typ”: “JWT”,  
“alg”: “ECDH-ES+A256KW”,  
“enc”: “A128CBC-HS256”,  
“key”: “”,  
“epk”: {  
“kty”: “EC”,  
“x”: “jrhYY29pTlx4C-wbFFlvDywq8zq2aqmkdEO4mR111Ag”,  
“y”: “LkK3YxUcIDr7aBhluEoq2eYZFlzhJyjvjgyHTJ\_21vY”,  
“crv”: “P-256”  
}  
}

Passing both public and private key  
// code snippet

```
	byte[] publicKeyData = Base64.getDecoder().decode((this.publicKeyAsString.getBytes()));
	X509EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(publicKeyData);
	byte[] privateKeyData = Base64.getDecoder().decode((this.privateKeyAsString.getBytes()));
	PKCS8EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(privateKeyData);

	KeyFactory fact = KeyFactory.getInstance("EC");
	ECPublicKey publicKey = (ECPublicKey) fact.generatePublic(publicKeySpec);
	ECPrivateKey privateKey = (ECPrivateKey) fact.generatePrivate(privateKeySpec);
	Algorithm algorithm = Algorithm.ECDSA256(publicKey, privateKey);
	JWTVerifier verifier = JWT.require(algorithm).build();
	DecodedJWT jwt = verifier.verify(token); // **Getting error in this line of code**
	return jwt.getClaim("client_id").asString();

```

> com.auth0.jwt.exceptions.JWTDecodeException: The token was expected to have 3 parts, but got 5.  
> at com.auth0.jwt.TokenUtils.splitToken(TokenUtils.java:21) ~[java-jwt-3.14.0.jar:3.14.0]  
> Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:  
> Error has been observed at the following site(s):  
> |\_ checkpoint ? org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]  
> |\_ checkpoint ? org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain]  
> |\_ checkpoint ? HTTP GET “/ugp-api/v1/product?src=web” [ExceptionHandlingWebHandler]  
> Stack trace:  
> at com.auth0.jwt.TokenUtils.splitToken(TokenUtils.java:21) ~[java-jwt-3.14.0.jar:3.14.0]  
> at com.auth0.jwt.JWTDecoder.(JWTDecoder.java:36) ~[java-jwt-3.14.0.jar:3.14.0]  
> at com.auth0.jwt.JWTVerifier.verify(JWTVerifier.java:282) ~[java-jwt-3.14.0.jar:3.14.0]

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [March 17, 2021, 12:13pm UTC](https://community.auth0.com/t/eorror-decoding-token-the-token-was-expected-to-have-3-parts-but-got-5/59558/2 "2021-03-17T12:13:52Z")

</div>

Unfortunately from our docs it seems that you need to do it manually:

> **[Validate JSON Web Tokens](https://auth0.com/docs/secure/tokens/json-web-tokens/validate-json-web-tokens)**
>
> Describes how to parse and validate a JSON web token (JWT).

but you can always create an issue in the repo you’re using so that repo maintainers can provide you with a more detailed answer.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [March 25, 2021, 10:21am UTC](https://community.auth0.com/t/eorror-decoding-token-the-token-was-expected-to-have-3-parts-but-got-5/59558/3 "2021-03-25T10:21:42Z")

</div>


