Generating JWT Token for use with Ghost

Options

Greetings!

I've read the Xano JWS Encode documentation and watched some tutorials on YouTube. However, I'm still struggling to execute successfully in practice. I'm trying to generate a JWT token for use with Ghost's API as shown in their documentation: https://ghost.org/docs/admin-api/#token-authentication .

Any tips on how to pull this off in Xano? Thanks!

Tagged:

Comments

  • advanceaudit
    advanceaudit Member
    edited October 2023
    Options

    For context, here's what I've got so far. I keep getting an invalid JWT signature error 401 when I try to execute the API.

    1. Create variable for the token header:

    2. Create variable for the token payload:

    3. Decode the hexadecimal secret into the original binary byte array and store in variable

    4. Create the JWS token:

    5. Try to use the token in an API call:

    However, I'm getting this error: Base64::decode() only expects characters in the correct base64 alphabet

    So even though the Ghost documentation ask for the secret to be decoded to binary, I'm removing that filter above and just passing the ghost secret.

    I then result in an error of invalid token:

    errors: [{message: Invalid token: invalid signature,context: null,type: UnauthorizedError,details: null,property: null,help: null,code: INVALID_JWT,id: 30b69d40-67c0-11ee-b6af-0197ef128098,ghostErrorCode: null}

    Any suggestions?