Embedding in Java Application failed!

good morning people

My dashboards embedded in a Java application have stopped working, now in the frame is the message "Message seems corrupt or manipulated." What is going on? Can someone help me?
I have already (several times) ruled the embed key on the Metabase server and it was no use.

Metabase Version: 0.33.3
Java 8

Hi @Lourival
It is really difficult to figure out what’s going on when embedding because it depends a lot on your code. Are you using exp to expire the token?
Are you using MB_ENCRYPTION_SECRET_KEY variable?

@flamber,
Yes, I am using EXP to control token expiration and tokenize URL, am I manually entering the secret key in my code? Is there any way to take the value of this MB_ENCRYPTION_SECRET_KEY variable and put it in my project to make the search for this key dynamic?

@Lourival
If you don’t know what the MB_ENCRYPTION_SECRET_KEY environment variable is, then you’re probably not using it, so ignore that.

Did the embedding just stop working from one day to another, without any changes anywhere? That means no updates, no configuration changes, no code changes.

Thanks @flamber, I will keep investigating!

Hey, I came across the same issue and I was super irritated. I tried many libraries, and this is the perfect one I found that works!
This is the library:

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;

This is the pom.xml incase you need it:

		<dependency>
			<groupId>com.auth0</groupId>
			<artifactId>java-jwt</artifactId>
			<version>4.3.0</version>
		</dependency>
   private static final String METABASE_SITE_URL = "your_url";
   private static final String METABASE_SECRET_KEY = "provided_key";

    @RequestMapping(value = "/metabase_embed_url", method = RequestMethod.POST)
    public ResponseEntity<Map<String, String>> getMetabaseEmbedUrl(@RequestBody Map<String, Object> payload) {
        try {
            long expiryTime = System.currentTimeMillis() + (10 * 60 * 60 * 1000);

            Map<String, Object> newPayload = new HashMap<>();
            newPayload.put("resource", payload);
            newPayload.put("params", new HashMap<>());
            newPayload.put("exp", expiryTime);

            // this gave errors upon trial.
//            String token = Jwts.builder()
//                    .setClaims(jwtPayload)
//                    .signWith(SignatureAlgorithm.HS256, METABASE_SECRET_KEY)
//                    .compact();

            Algorithm algorithm = Algorithm.HMAC256(METABASE_SECRET_KEY);
            String token = JWT.create()
                    .withPayload(newPayload)
                    .sign(algorithm);

            String iframeUrl = METABASE_SITE_URL + "/embed/dashboard/" + token + "#bordered=true&titled=true";
 
            return ResponseEntity.ok(iframeUrl);
        } catch (Exception e) {
            throw new ServiceException("ERR", e.getMessage());
        }
    }
}