CLI and device login
Getting a key onto a machine that has no browser, without copying and pasting a secret around.
The CLI package is not published yet
@makeaivideo/cli is built and tested but is not on npm, so there is nothing to install today. The device-code endpoints it uses are live now, and everything on this page works with plain curl. This page will get install and command docs when the package ships.
Device-code flow
Standard RFC 8628. The machine asks for a code, a human approves it in a browser somewhere else, and the machine collects the key. These two endpoints are the only unauthenticated ones in the API.
1. Start a login
curl -X POST https://app.makeaivideo.ai/api/v1/auth/device \
-H "Content-Type: application/json" \
-d '{ "client_name": "my-laptop" }'{
"data": {
"device_code": "...",
"user_code": "....-....",
"verification_uri": "https://app.makeaivideo.ai/device",
"verification_uri_complete": "https://app.makeaivideo.ai/device?code=...",
"expires_in": <seconds>,
"interval": <seconds between polls>
},
"error": null,
"meta": { ... }
}Show the user user_code and send them to verification_uri. If they are on the same machine, verification_uri_complete skips the typing.
2. Poll for approval
Poll every interval seconds until the code expires.
curl -X POST https://app.makeaivideo.ai/api/v1/auth/device/token \
-H "Content-Type: application/json" \
-d '{ "device_code": "..." }'| status | What to do |
|---|---|
| pending | Nobody has approved it yet. Keep polling at the given interval. |
| slow_down | You are polling too fast. Back off, then continue. |
| authorized | Approved. api_key is present, once. Store it now. |
| denied | The user rejected the request. Stop. |
| expired | The code timed out. Start a new device login. |
3. Store the key
{
"data": {
"status": "authorized",
"api_key": "mav_...",
"api_key_id": <integer>
},
"error": null,
"meta": { ... }
}api_key is returned once and never again. Write it to your config or keychain on receipt. From there it is an ordinary bearer key, as described in Authentication.
CLI questions
- Is there a MakeAIVideo CLI?
- It is built but not yet published to npm, so there is nothing to install today. The device-code endpoints it uses are live, and this page shows the same flow with curl.
- How do I log in from a server or a terminal?
- Use the device-code flow. Request a code, approve it in a browser on any device, and your client polls until it receives the API key. Nobody has to paste a secret into the terminal.
- Can I get the API key back if I lose it?
- No. It is returned once on the authorized response and never again, so write it to your config or keychain immediately and issue a new key if it is lost.