1. Prepare PKCE
For every authorization, generate a randomcode_verifier (43 to 128 characters from A-Z, a-z, 0-9, -, ., _, ~) and its S256 challenge:
-A flags: without them openssl base64 breaks long output into lines, and a verifier with a line break in it fails the exchange with invalid_grant.
PKCE is required for desktop, mobile and script applications. Server applications may leave it out, but should not: it costs nothing and protects the code. Only S256 is accepted; plain is refused.
2. Send the user to Drime
The user signs in to Drime if they are not signed in yet (password, two-factor, passkey or Google: you implement none of it). Then they see the authorization screen: your application’s name and what it asks for. They can untick permissions before approving. The screen shows every time, including to someone who already approved your application.
If
client_id or redirect_uri is wrong, Drime shows the error on its own page and sends nobody to the URL: an address you did not register never receives anything.
3. Drime sends the user back
state is the value you sent, and refuse the request otherwise.
If the user declines, you get ?error=access_denied, with error_description and your state, and no code.
The code is valid for 60 seconds and works once. A failed exchange uses it up as well: start a new authorization.
4. Exchange the code for tokens
redirect_urimust be the one used in step 2.- A server application may send its credentials with HTTP Basic instead of the body (RFC 6749, section 2.3.1). If it sends both, Basic is used.
- A desktop, mobile or script application sends no secret. Sending one is refused.
scope instead of assuming it. It holds what you were actually given:
- sometimes more than you asked for, because a
.writescope always brings its.read; - sometimes less, because the user may have unticked a permission;
- never anything the user did not approve.
GET /api/v1/users/me once and store user.id with the tokens: webhooks name accounts by this id.
5. Call the API
6. Refresh
Access tokens last one hour. Refresh tokens last 90 days and rotate: each refresh returns a new refresh token, valid 90 days again, and retires the one you sent. The access token you had stops working at the same time.scope to narrow the new access token to part of what you were granted. Scopes you were not granted are never added, and a request for nothing but those answers invalid_scope.
7. Revoke
When a user disconnects Drime from inside your application, revoke the refresh token:- A refresh token ends the authorization: every token your application holds for that user stops working.
- An access token ends only that token. The refresh token keeps working.
- A token that is unknown or already revoked answers
200too, as RFC 7009 requires. Wrong client credentials answer401withinvalid_client.
Redirect URLs
- Compared exactly, after normalizing the case of the scheme and host. No prefix, no wildcard, no subdomain matching.
https://only, excepthttp://127.0.0.1,http://[::1]andhttp://localhostfor applications running on the user’s own machine.- On
127.0.0.1and[::1]the port is ignored (RFC 8252, section 7.3), so a desktop application can listen on whatever port is free.localhostkeeps its port. - No fragment, no wildcard, no credentials in the URL, no
... - Custom schemes such as
myapp://callbackare refused: any other application on the same machine can register the same scheme and catch the code. Use the loopback address instead. - Up to 10 redirect URLs per application, 2,000 characters each.