[SOLVED] Problems when embedding questions


#1

Hello !

So i’m currently playing with the metabase secure embedding.
I’m currently trying to embed questions, i’ve took some PHP sample to do this, here’s a sample :

$metabaseSiteUrl = 'http://localhost';
$metabaseSecretKey = 'MYSUPERSECRETKEY';
$signer = new \Lcobucci\JWT\Signer\Hmac\Sha256();
$token = (new \Lcobucci\JWT\Builder())
    ->set('resource', ['question' => 1])
    ->set('params', [])
    ->sign($signer, $metabaseSecretKey)
    ->getToken();

$iframeUrl = "$metabaseSiteUrl/embed/question/$token#bordered=true&titled=true";
?>
<iframe
        src="<?php echo $iframeUrl ?>" frameborder="0"
        width="100%"
        height="800"
        allowtransparency
></iframe>

I’ve tried this with two different questions (both questions doesn’t take any custom settings). And for both question, the frame display this message : Assert failed: (map? token-params)

To be honest, i don’t have any idea of the problem (tried another jwt generation library, same problem)

If anyone have an idea about this problem, feel free to answer :slight_smile:

Thanks !


#2

I haven’t encountered that error, but looking at your code and comparing it to mine I noticed that I reference a port in the site url.

$metabaseSiteUrl = ‘http://localhost:3000’;


#3

Thanks for your answer Jonathan !

In fact, Metabase is installed on another server on my local network.
The variable is defined like this :
$metabaseSiteUrl = ‘http://MY_NETWORK_IP:3000’;


#4

By the way, i’ve tried the nodejs sample code provided in the metabase UI and i don’t encounter any problems.

Must be a problem with my PHP code, wich is directly inspired from the example provided in the laravel sample app.

Also tried to play with dashboard, when i display the iframe, i see the different blocks of my differents questions of the dashboard but each question block display the message Assert failed: (map? token-params)

EDIT : Solution found !
In the params i have to pass an empty array with the param key