JWT token issue

Options
i am using third party microservice rest api that api use only jwt token for auth.
how can i access that api in xano because xano not support jwt token.
how can i create jwt token in xano??

Comments

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options
    A JWT token is just a string that is usually sent via header to authorize a given request. 99% of the time, there's not much to working with it. The work is usually getting the token as part of an authentication dance with the provider. I've seen a number of Xano implementations make this work. The how of it depends on the details of the API. Which service are you trying to integrate with? 
  • Khan aqib
    Options
    getstream io service integrate with xano
  • Khan aqib
    Options
    https://getstream.io/chat/docs/rest/#introduction
    please read the Authentication part in above link if your understand please help me
  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options
    Yep, you can create a JWT with https://jwt.io to based on your secret API key. Based on this documentation, there's no date requirement so you can make it once and use it many times. You save that key in Xano (there are a few ways to do that) and repeatedly use it for your calls. You can build this on your own, or I'd be glad to set up a consulting call to help over a zoom. 
  • Khan aqib
    Options
     thanks for quickly reply
    The zoom call is not possible
    Can you help me here please
  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options
     Here's a loom I made walking through the core of the authentication process. I'm not a stream user so I haven't tested it, but hopefully points you in the right direction: https://www.loom.com/share/29d53a33b31746c797c974e228710e4d
  • Khan aqib
    Options
     thanks for help
    I will try this method
  • cameronwetherby
    Options

    @Ray Deck Based on my understanding of the documentation, doesn't each user need to have a JWT token with the user_id passed through and with the API Secret key used as the signature. If true, it wouldn't make much sense to make the JWT token on an external site right? Is there a way to create the auth token with those attributes directly in xano, and have it be the same auth token Xano uses to authenticate users? That way, each user sends the right auth token to getstream to be verified.

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options

    Hi Cameron! I'm not sure what problem you are trying to solve. Can you expand a bit on your question?

  • cameronwetherby
    Options

    @Ray Deck

    Hey Ray, thanks for the response. I have the GetStream Chat API integrated into my app and the only issue left is the authentication (you can disable authentication with GetStream for development purposes). So, I haven't been able to send the right auth token from Xano to the frontend to authenticate the user.

    After watching your video above, it seems like you're creating an auth token on https://jwt.io and using that to send to the frontend. My question is, while that might work for one user, I believe every user has to have a different auth token sent to the frontend. So, is there a way to create a jwt auth token inside of xano to send to the frontend that includes the right signature(API Secret), instead of having to create it on https://jwt.io?

    Hopefully this makes more sense? Let me know if it's still confusing.

  • nocodetalks
    nocodetalks Member ✭✭
    Options

    @cameronwetherby


    Since the https://jwt.io create the token using-


    You can create the header and payload object as the variable.

    Use the Base64_encode filter to encode the "header" and "payload".



    After that, Use the "hmac_sha256" security filter to further filter the contacted string of header_object and payload_object.



  • cameronwetherby
    Options

    @nocodetalks

    I can tell I'm getting close, but I think I'm still missing something. So, for example, if I need a token that doesn't require a header and needs the user_id passed as a parameter in the payload, here is what I have right now: (The Stream_Secret variable is what I need the signature to be)


  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    edited November 2022
    Options

    @cameronwetherby This is a neat, complicated problem that I think would resolve in a few minutes (potentially more easily if you have access to the lambda - e.g. are on a paid plan for Xano) If you like, you can join one of our State Change office hours today or tomorrow with my compliments. Here's a ticket you can redeem for one free session to participate: https://tickets.statechange.ai/ticket/48458950-e27b-47b3-863c-1a43fa088a6e

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options

    @cameronwetherby Here is another token you can use for joining us if you like (first one was redeemed by another community member!) - our next office hours is tomorrow! https://tickets.statechange.ai/ticket/4f8eb684-2e23-4007-903a-1d58b1df138e