Walk15 Connect V1
OAuth and PKCE
Authorization code flow with S256 PKCE, confidential client authentication, token rotation and revocation.
Walk15 Connect uses the OAuth 2.0 authorization code grant with mandatory S256 PKCE and confidential client authentication. Users authorize in a browser; everything else happens between your backend and Walk15.
- 1User's browser → Your backendUser clicks “Connect Walk15”
- 2Your backendCreate state + PKCE verifier, store server-side
- 3Your backend → User's browser303 redirect to /oauth/authorize
- 4User's browser → Walk15 ConnectGET /oauth/authorize
- 5Walk15 Connect → User's browserWalk15 sign-in and consent
- 6Walk15 Connect → User's browser303 to your callback ?code&state
- 7User's browser → Your backendGET /your/callback?code&state
- 8Your backend → Walk15 ConnectPOST /oauth/token + code_verifier + application_user_id
- 9Walk15 Connect → Your backendTokens, history_from
- 10Your backend → Walk15 ConnectGET activity with Bearer token
Supported: response_type=code, the authorization_code and refresh_token grants, PKCE method S256, and client_secret_basic client authentication. Not supported: implicit, password, client-credentials and device grants; OpenID Connect and ID tokens; dynamic client registration; token introspection; incremental consent.
Discovery
Authorization server metadata is published at the issuer root:
curl "$WALK15_ISSUER/.well-known/oauth-authorization-server"{
"issuer": "https://api.walk15.lt",
"authorization_endpoint": "https://api.walk15.lt/oauth/authorize",
"code_challenge_methods_supported": ["S256"],
"token_endpoint": "https://api.walk15.lt/oauth/token",
"revocation_endpoint": "https://api.walk15.lt/oauth/revoke",
"token_endpoint_auth_methods_supported": ["client_secret_basic"],
"revocation_endpoint_auth_methods_supported": ["client_secret_basic"],
"scopes_supported": ["daily_steps:read", "cycling_activities:read"],
"response_types_supported": ["code"],
"grant_types_supported": ["authorization_code", "refresh_token"]
}The issuer is the exact HTTPS origin Walk15 gives you; all paths are rooted there. scopes_supported lists every scope Connect knows, regardless of the scopes your company is allowed to request.
Client authentication
The token and token-revocation endpoints require HTTP Basic authentication with your client ID and secret:
- Encode the client ID and the secret separately with
application/x-www-form-urlencoded(RFC 6749 §2.3.1). Walk15 client IDs and secrets contain only URL-safe characters, soencodeURIComponentgives the same result. - Join them with
:and base64-encode the result. - Send exactly one
Authorization: Basic <value>header.
Credentials or client assertions in the body or query string return 400 invalid_request. A missing or repeated Authorization header, or any other failed client authentication, returns 401 invalid_client with a WWW-Authenticate: Basic challenge.
Authorization request
Redirect the user's browser to GET /oauth/authorize (parameters and limits are listed there). Never put a secret, token, verifier or user identifier in this URL.
- State. A fresh random value per attempt, stored with the initiating user's session and a short expiry, accepted once and only for that same user. Walk15 returns it unchanged.
- PKCE. A verifier of 43–128 characters from
[A-Za-z0-9._~-]that stays on your backend; sendcode_challenge = BASE64URL(SHA256(verifier)). The PKCE example produces a compliant pair. - Redirect URI. Compared with the registered value as an exact string. A registered query string must not contain
code,state,errororerror_description. - Lifetime. Sign-in and consent must complete within 10 minutes. Each authorization requires sign-in or explicit confirmation of the Walk15 account.
Sign-in and consent
Walk15 shows the user:
- Walk15 handles sign-in to an existing account using the methods it makes available, such as an email code, supported sign-in providers or the Walk15 app. Walk15 configures these methods; your integration needs no provider-specific setup. All methods lead to browser consent and use the same partner authorization URL, callback and code exchange. No Walk15 account is created.
- The consent screen explains the requested access. The sign-in pages already show your company name. Consent shows:
- Your company display name, purpose and privacy policy link.
- The signed-in Walk15 account and an option to switch accounts.
- Every requested dataset.
- "Access starts on {date} ({timezone})".
- An explanation that permission has no fixed expiry but requires renewal within the inactivity period.
- Allow access and Cancel.
Consent records a pending approval. An existing connection is replaced only when a code exchange succeeds; canceled, expired, failed-PKCE, stale and rejected attempts leave it usable. See account collisions.
Consent is all-or-nothing. If the user's connection with your company has not been disconnected (even if it lapsed or its tokens were revoked) and uses a different set of scopes, Allow is disabled and the user is told to disconnect first. See Changing scopes.
Callback and code exchange
Walk15 redirects to your redirect_uri with ?state=…&code=…, or ?state=…&error=access_denied if the user cancels. Walk15 displays invalid or expired authorization requests on its own error page. This includes an incorrect client, a redirect mismatch, invalid scopes or PKCE, an expired request, or a consent page left open past the user's local midnight. These errors are not redirected to your callback.
Exchange the code within 5 minutes (less if the 10-minute authorization request ends sooner) at POST /oauth/token. The code is single-use and bound to your client, callback, PKCE challenge, scopes and the current connection version; any mismatch returns a generic 400 invalid_grant. Send the application_user_id of the user who started the flow; Walk15 binds the connection to it. Store the response as described in Getting started.
Using access tokens
Send exactly one header:
GET /connect-walk15/v1/summary?from=2026-10-10&to=2026-10-12 HTTP/1.1
Host: api.walk15.lt
Authorization: Bearer w15a_<access-token>Access tokens are opaque and last at most five minutes (expires_in is the remaining lifetime in seconds). A refresh does not revoke the previous access token; it keeps working until it expires. Each token identifies one connection, so activity and disconnect requests carry no user or connection ID. Use the token you stored for that application_user_id. Refresh shortly before expiry rather than waiting for a 401.
Refresh-token rotation
Refresh at POST /oauth/token with grant_type=refresh_token. Each refresh token works once: a successful refresh returns a new access token and a new refresh token, which must replace the old pair atomically.
application_user_id,scope,history_fromandconnection_versionare unchanged by a refresh.- Each successful refresh restarts the 90-day inactivity period, currently the same for every customer (the consent screen states the exact number). If no refresh succeeds within that period, the user must reconnect. No webhook announces the lapse. To keep idle connections authorized, refresh them before the period ends, for example after 60 days.
- There is no absolute lifetime: a connection you keep refreshing can stay authorized for years, until the user or Walk15 revokes it, the user deletes their account, or your client is disabled.
- Refreshing does not move the access start date.
Run at most one refresh per connection at a time across all your instances. Hold a session advisory lock while refreshing, and commit the recovery marker before the network request. A row lock inside one transaction cannot protect against a crash or rollback after Walk15 consumes the token:
import { refreshTokens } from "./token-client";
import { Walk15Error, type Walk15Config, type Walk15Tokens } from "./walk15-config";
export type StoredConnection = Walk15Tokens & { accessExpiresAt: number; needsReauthorization: boolean };
export interface ConnectionStore {
/**
* Hold the same exclusive per-user lock as authorization, disconnect and webhook processing
* across all instances, including when no connection exists. Use a session advisory lock on
* a dedicated PostgreSQL connection, released in finally; do not wrap fn in a transaction.
* Read the current connection only after acquiring the lock.
*/
withConnectionLock<T>(applicationUserId: string, fn: (connection: StoredConnection | undefined) => Promise<T>): Promise<T>;
/** Commit this write before returning, independently of later failures inside the lock. */
save(connection: StoredConnection): Promise<void>;
}
const REFRESH_MARGIN_MS = 30_000;
export const getAccessToken = (config: Walk15Config, store: ConnectionStore, applicationUserId: string): Promise<string> =>
store.withConnectionLock(applicationUserId, (connection) => getAccessTokenLocked(config, store, connection));
/** For callers already holding the shared per-user lock, such as the webhook worker below. */
export const getAccessTokenLocked = async (
config: Walk15Config, store: ConnectionStore, connection: StoredConnection | undefined,
): Promise<string> => {
if (!connection || connection.needsReauthorization) throw new Walk15Error(401, "reauthorization_required");
if (connection.accessExpiresAt - Date.now() > REFRESH_MARGIN_MS) return connection.access_token;
// Commit before sending: a crash or failed token save must never replay the old refresh token.
await store.save({ ...connection, needsReauthorization: true });
connection.needsReauthorization = true;
let next: Walk15Tokens;
try {
next = await refreshTokens(config, connection.refresh_token);
} catch (error) {
// Walk15 answers these before applying the refresh: clear the marker so a later call retries the
// same token. Any other failure leaves the marker set, because the token may be consumed.
if (error instanceof Walk15Error && (error.code === "invalid_client" || error.code === "temporarily_unavailable")) {
await store.save({ ...connection, needsReauthorization: false });
connection.needsReauthorization = false;
}
throw error;
}
if (
next.application_user_id !== connection.application_user_id ||
next.history_from !== connection.history_from ||
next.connection_version !== connection.connection_version
) throw new Error("Refresh returned tokens for a different connection");
const updated = { ...next, accessExpiresAt: Date.now() + next.expires_in * 1000, needsReauthorization: false };
await store.save(updated);
Object.assign(connection, updated);
return next.access_token;
};When refresh fails
| Response | Meaning | What to do |
|---|---|---|
400 invalid_grant | Refresh token expired through inactivity, already used, revoked, the user/connection is gone, or a granted scope is no longer allowed | Mark the connection as needing reauthorization and ask the user to reconnect Walk15 from your app. If your company's allowance lost a scope, follow the scope-removal steps below first. |
401 invalid_client | Your client ID/secret is wrong, replaced or disabled | Fix your configuration; the refresh token was not consumed |
503 temporarily_unavailable | Walk15 was unavailable and did not apply the refresh | Keep the refresh token and retry later with backoff. If a retry returns invalid_grant, ask the user to reconnect. A 503 without this error code counts as no response. |
Any other 5xx or no response | Outcome unknown; the token may have been consumed | Do not resend the same refresh token. Mark the connection as needing reauthorization and ask the user to reconnect Walk15 from your app. |
If Walk15 removed a scope from your company's allowance, the user must first disconnect the old connection in Walk15 Connected Apps. If they cannot do so, contact Walk15 to end the connection. Then reconnect with scopes your company is still allowed to request.
When reconnection is required, your partner app should show Reconnect Walk15 and open the usual Walk15-hosted authorization flow. After the user completes it, your backend exchanges the new authorization code and securely stores the fresh tokens. The user does not need to create a new Walk15 account.
Replay protection
If your client presents an already-used refresh token, Walk15 treats it as a possible theft and revokes all access and refresh tokens for that connection version. This includes any refresh token issued moments earlier by a concurrent request. Walk15 returns invalid_grant and, if you use webhooks, sends connection.revoked. Ask the user to reconnect Walk15 from your app. Credentials from an older connection_version, another customer or malformed values cannot affect the current connection.
This is why refreshes must be serialized and why an uncertain refresh must never be retried blindly.
Revocation
| Action | Endpoint | Effect |
|---|---|---|
| Revoke one access token | POST /oauth/revoke with an access token | That access token stops working |
| Revoke the credential family | POST /oauth/revoke with a refresh token | All tokens of this connection version stop working; a connection.revoked webhook is sent. The user's consent record remains, so re-authorizing with the same scopes keeps the original history_from. |
| Disconnect the user | DELETE /connect-walk15/v1/connection with the connection's access token | Ends the connection completely. Reconnecting later requires fresh consent and starts a new access window on the new authorization day. |
A connection.revoked webhook confirms that the version's credentials stopped working. It does not by itself confirm a disconnect: refresh-token revocation and replay leave consent in place. Likewise, a refresh returning invalid_grant does not prove consent ended. See Disconnect connection for recovery after a lost disconnect response.
Use the disconnect endpoint when a user unlinks Walk15 in your product or closes their account with you. Revocation applies to requests that start afterwards. A read already in progress can still complete, and Walk15 cannot recall data you already received.
Users can also disconnect from Connected Apps in the Walk15 app, and Walk15 revokes connections when a user deletes their account or when a customer is offboarded.
Credential storage
Keep the client secret and all tokens on your backend only, encrypted at rest, and out of logs, error trackers, analytics and support tickets. Never send them to a browser or mobile app; give the app your own session instead. Treat every credential as opaque; the current prefixes help with secret scanning and log redaction:
| Value | Current prefix |
|---|---|
| Client secret | w15i_ |
| Authorization code | w15c_ |
| Access token | w15a_ |
| Refresh token | w15r2_ |
| Cycling cursor | cc1_ |