-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Description
Problem Description
Linear OAuth access tokens expire after 24 hours, but Cyrus does not implement the proper refresh token flow as documented in the Linear OAuth 2.0 documentation. This causes authentication failures and requires manual re-authorization daily.
Current Behavior
- Linear OAuth tokens (
LINEAR_OAUTH_TOKEN) expire after 24 hours - When tokens expire, Cyrus fails with authentication errors
- Users must manually re-authorize to continue using Cyrus
- No automatic refresh token mechanism is implemented
Expected Behavior
According to Linear's OAuth documentation, Cyrus should:
- Store the
refresh_tokenreceived during initial authorization - When receiving a 401 error or detecting token expiration, automatically use the refresh token to obtain a new access token
- Update the stored access token with the new one
- Continue operations without user intervention
Steps to Reproduce
- Set up self-hosted Cyrus App with Linear OAuth authentication
- Deploy CloudFlare Worker Proxy
- Run local Cyrus CLI, authorize with Linear OAuth
- Wait 24 hours for the token to expire
- Attempt to run Cyrus with the expired token
- Observe authentication failure requiring manual re-authorization
EdgeWorker error: Error: Linear authentication failed for Portfolio. The Linear OAuth token may have expired or been revoked. Please re-authenticate with Linear to obtain a new token.
at WebhookTransport.registerWebhook (file:///opt/cyrus/packages/ndjson-client/dist/transports/WebhookTransport.js:137:39)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {
code: 'LINEAR_AUTH_FAILED',
isAuthError: true
}
❌ Linear authentication failed for repository: sandbox
Workspace: 18544a12-e52c-4e40-81e1-766e0c46650e
Error: Linear authentication failed for Portfolio. The Linear OAuth token may have expired or been revoked. Please re-authenticate with Linear to obtain a new token.
To fix this issue:
1. Run: cyrus refresh-token
2. Complete the OAuth flow in your browser
3. The configuration will be automatically updated
❌ Failed to start edge application: Failed to connect any repositories. Please check your configuration and Linear tokens.
Technical Details
The Linear API refresh token flow requires:
POST https://api.linear.app/oauth/token
Content-Type: application/json
{
"grant_type": "refresh_token",
"refresh_token": "<stored_refresh_token>",
"client_id": "<client_id>",
"client_secret": "<client_secret>"
}
Impact
- Daily manual re-authorization disrupts automated workflows
- Breaks continuous integration/deployment pipelines
- Reduces the reliability of Cyrus as an automation tool
Related Issues
- Cyrus shutting down with authentication errors from linear #265: Authentication errors from Linear (symptom but not root cause)
- PR Improve Linear token error handling and centralize config location #85: Added
cyrus refresh-tokencommand but doesn't implement automatic refresh flow
Suggested Solution
Implement automatic refresh token handling:
- Store refresh tokens securely alongside access tokens
- Implement token refresh logic before API calls or on 401 responses
- Automatically retry failed requests after token refresh
- Only require user re-authorization if refresh token is invalid/expired
Metadata
Metadata
Assignees
Labels
No labels