Code Steps

Code Steps

Code steps are pages just like this one, where you can show the steps to achieving something in code. To add a code step:

  • From the index, click on a .
  • Choose Code Steps

To demonstrate Code Steps, this is an example of how you could use auto$ on DeveloperHub.

This example uses express as the backend server.

1Install JWT library

First, to generate JWT, it is easier to do it using a library. To install jsonwebtoken, run npm install jsonwebtoken.

2Get API Key

The JWT would be signed using the API Key. Get your auto$ and save it in the code.

3Set the payload

The payload is the information being sent securely using JWT. The payload for Custom Login is a JSON object and it must have two properties.

version must be set to 1

vars contains the variables to set when the docs load. You could personalise the docs for the user here.

4Set Expiry

Setting a shorter expiry ensures that if a JWT falls into the wrong hands. We recommend a day.

5Sign the token

Sign the token with the API key, setting the expiry.

6Generate the URL

The URL contains the path that the reader tried to access and a query param jwt containing the token.

7Redirect the user with the token

Finally, redirect the user back to the docs with the signed token.

developerhub.js
server.js
Copy
VariableType to search · ESC to discard
GlossaryType to search · ESC to discard
InsertType to search · ESC to discard
No matches
  Last updated