Generating Auto-Login URLs

Step 1: Generate an Org API Key

Click the "Administration" page in the top right

Go to the "Api Keys" tab, click "Create Key" and copy down this token for later

Creating temporary login tokens

The GraphQL api for this call is as follows:

mutation createLoginToken(email: String!, name: String, orgRole: OrgRole): String!

You can call the graphql api at /graphql using your new org api token as a bearer token. If the specific user doesn't exist, a new one will be created. orgRole and name will be ignored if the user already exists, and are only used for new user creation.

example using curl:

curl --location --request POST '<https://staging.hex.site/graphql>' \\
--header 'Authorization: Bearer 6031f199750bae31a120e4b2bd008dbdfe3ccba5b8827a0b35df9d9a5b071e55d3b8d0800b608a55b30cfebe1a70073f' \\
--header 'Content-Type: application/json' \\
--data-raw '{"query":"mutation CreateLoginToken {\\n createLoginToken(email: \\"[email protected]\\", name: \\"Auto Jim\\", orgRole: MEMBER)\\n}","variables":{}}'

This will return a new token which can be used to generate the URL. This token is valid for 60 seconds only.

Constructing the auto-login url

Using the token returned, you can now create a url that automatically logs in a user and optionally redirects them to something.

https://app.hex.site/auth/auto-login?token=1eb16e8a66df378c3003c0ffbc04038d510558b4655788719d90cc0235c8e6f09d7479deeea45e8278185c7c4ca29c47&redirectTo=https://app.hex.site/global/hex/e289ab40-d077-4885-a9fc-c2f072394b9d/draft/logic