Magic link Xano / Bubble

Options
djcedr
djcedr Member

Hi,

I've followed the great tutorial here https://www.youtube.com/watch?v=eWIpAPrNeuc&list=PLOch5nUqQ_Y6eyPlp15BGBlQRJjFWnmtT&index=4

But contrary to what is shown in the video, when trying to initialize the API call for /auth/magic-login, I get the following error message:

You have set the data type of this call to JSON/XML, but what is returned is not an object, but a text. Please check your settings. 

Any idea?

Thanks for your help.

Best,

Tagged:

Comments

  • djcedr
    djcedr Member
    Options
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options

    Hi @djcedr so this is a Bubble error because you are using selecting data type of JSON on the Bubble API connector. It sounds like what's happening is on the /auth/magic-login endpoint you are returning the raw token. You might see in the response of this endpoint it says "as self". If you update the response to give the token a key (something like authToken or token) then this will create a JSON object and should help you get around this error in Bubble.

  • djcedr
    djcedr Member
    Options

    Hi @Michael Udinski, thank you very much, problem solved thanks to your reply!

  • Douglas Gouveia
    Options

    Hi @Michael Udinski and @djcedr. Could you please send pictures showing how to solve this problem?

    I didn't understand how to set the solution given by @Michael Udinski

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options

    Hey @Douglas Gouveia

    No problem. So by default, the API response returns the raw value of the token. But when JSON is the data type selected in the Bubble API connector, this means Bubble is expecting a JSON object with a key-value pair.

    Below is how the API is set up, returning the token as a value

    Click on the response and add a name to create a key for the token.

    The result looks like this:

    This transforms the response from:

    eyJhb…..

    To

    {

    "token":"eyJhb…"

    }

  • Douglas Gouveia
    Douglas Gouveia Member
    edited February 2023
    Options

    It still not working for me. What worked was changing on Bubble the data type from JSON to text.

    The API worked by doing this, but the workflow didn't.