Skip to content

Add refreshTokenUrl to enable automatic OAuth token refresh#3

Open
jacobhaug wants to merge 1 commit into
ThinkOodle:masterfrom
jacobhaug:fix/oauth-token-refresh
Open

Add refreshTokenUrl to enable automatic OAuth token refresh#3
jacobhaug wants to merge 1 commit into
ThinkOodle:masterfrom
jacobhaug:fix/oauth-token-refresh

Conversation

@jacobhaug
Copy link
Copy Markdown

Problem

Users are experiencing OAuth token expiration errors every 1-2 weeks, requiring manual reconnection of their Basecamp OAuth credentials. The error message "Missing code query parameter" appears when access tokens expire, forcing users to manually reconnect through the n8n UI.

Solution

Added the refreshTokenUrl property to the OAuth2 credentials configuration. This enables n8n's built-in OAuth2Api base class to automatically refresh expired access tokens using the stored refresh token, eliminating the need for manual reconnection.

Changes

  • Added refreshTokenUrl property to Basecamp4OAuth2Api.credentials.ts
  • Set to the same endpoint as accessTokenUrl: https://launchpad.37signals.com/authorization/token?type=web_server

How It Works

When n8n detects an expired access token, it will:

  1. Automatically use the stored refresh token
  2. Make a request to the refreshTokenUrl endpoint
  3. Obtain a new access token (and potentially a new refresh token)
  4. Update the stored credentials automatically
  5. Retry the original API request

This all happens transparently in the background without user intervention.

Testing

  • Verified the refresh token URL matches Basecamp's token endpoint
  • Confirmed compatibility with n8n's OAuth2Api base class

User Impact

After this change is merged and users update to the new version:

  • Users will need to reconnect their OAuth connection once to ensure a refresh token is properly stored
  • After that initial reconnection, tokens will refresh automatically
  • No more manual reconnection required every 1-2 weeks

References

Ticket: #2

This fixes the issue where users had to manually reconnect their OAuth
connection every few weeks when access tokens expired. By adding the
refreshTokenUrl property, n8n will now automatically refresh expired
tokens using the stored refresh token, eliminating the need for manual
reconnection.
@afroximity
Copy link
Copy Markdown

Nice! I confirm that this is working.

@jacobhaug
Copy link
Copy Markdown
Author

@ryanrhughes can you review and merge please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants