Exchange a JWS/JWE Token for a Xano Auth Token
In this step-by-step guide, we'll walk through the process of decoding the token received from Memberstack and translating it into a Xano token. This will enable secure authentication and authorization for your web or mobile application using the Xano platform.
Step 1: Decode the Memberstack Token
First, you need to decode the token you're receiving from Memberstack. This can be done using the JWSD function in Xano.
- In the Xano dashboard, navigate to the
Securitysection and click onJWSD. - Set the
JWT Tokeninput to the token you received from Memberstack. - Copy the public key from the Memberstack documentation by clicking on "Find public keys" and copying the content between
-----BEGIN PUBLIC KEY-----and-----END PUBLIC KEY-----. - Paste the public key into the
Public Keyfield in Xano. - Set the
SignaturetoRS256. - Click
Save.
Now, you should see the decoded token output, including the user's name, email address, and Memberstack ID.
Step 2: Store User in the Database
Next, you'll want to store the user in your Xano database for future reference.
- Create a new table (e.g.,
users) in your Xano project to store user information. - Add the relevant fields to the table, such as
name,email, andmemberstackID. - Insert a new record into the
userstable, using the decoded token information from the previous step.
Step 3: Generate Xano Token
With the user information stored in your Xano database, you can now generate a Xano token for authentication and authorization purposes.
- In the Xano dashboard, navigate to the
Securitysection and click onAuth Token. - Set the
Tableto the table you created for storing user information (e.g.,users). - Set the
IDto the ID of the user record you just created. - Set the
Expiresfield to specify the token's expiration time (e.g.,1hfor one hour). - Click
Save.
You should now see the generated Xano token in the output.
Step 4: Use the Xano Token
Finally, you can use the generated Xano token for authentication and authorization purposes in your application.
- If you have any locked-down endpoints in your Xano project, you can pass the Xano token in the
Authenticationheader to access them. - Alternatively, you can use the Xano token in your frontend application to make authenticated requests to your Xano APIs.
By following these steps, you've successfully decoded the Memberstack token, stored the user information in your Xano database, and generated a Xano token for secure authentication and authorization purposes.
Sign up for Xano.
100,000+ people build on Xano.
Start today and scale to millions.