Sign in with Thrixel
Let your users connect their Thrixel account to your app in three steps.
Add a "Sign in with Thrixel" button to your app. Your user approves once in a browser, you get their API key, and you call the API as them. They never see or paste a key.
Three requests. No app registration, no client secret, nothing to wait for.
1. Ask for a code
Call this from your server when the user clicks your button.
curl -X POST https://api.thrixel.com/api/v1/cli/device/start \
-H "Content-Type: application/json" \
-d '{
"client_name": "Your App Name"
}'2. Send the user to approve
Open verification_uri_complete in a popup or new tab, and show them
user_code so they can check it matches.
They sign in, confirm, approve. If they have no Thrixel account yet, they can sign up on that same page.
Keep device_code on your server. It is the secret that collects the key.
3. Poll for the key
Every interval seconds, until it returns the key.
curl -X POST https://api.thrixel.com/api/v1/cli/device/poll \
-H "Content-Type: application/json" \
-d '{
"device_code": "kL9x..."
}'Store api_key against that user. Show them email so they know which account
they connected. Done.
While you wait, poll returns 400 with one of these in detail.error:
| Error | What to do |
|---|---|
authorization_pending | Not approved yet. Keep polling. |
slow_down | You polled too fast. Wait longer, then continue. |
access_denied | They declined. Stop. |
expired_token | Expired or already collected. Start again at step 1. |
Complete example
Keep the key on your server
It has full access to that user's account, including their cubes. Never put it in the browser or in a URL.
Before you ship
- Codes expire in 10 minutes. If nobody approves in time, start over.
- The key is delivered once. Store it on the first successful poll.
- Jobs bill to the user, on their plan and their limits. Not yours.
- On a
401, run the flow again. The user can revoke your key from their account, and reconnecting your app replaces the key you were holding. - Set
client_nameto your app's name. Your user sees it on the approval screen and in their account afterwards.