Issue with OAuth2 (PKCE) authentication

Hi n8n team,

I hope you are doing well.

We are facing an issue while updating OAuth2 credentials at the database level in n8n.

Problem Description

We are using OAuth2 (PKCE) authentication for Canva integration. The credential configuration includes:

  • OAuth Redirect URL

  • Grant Type: PKCE

  • Authorization URL: https://www.canva.com/api/oauth/authorize

  • Access Token URL: https://www.canva.com/api/oauth/token

  • Client ID

  • Client Secret

  • Scope: design:meta:read design:content:read profile:read

  • Auth URI Query Parameters: response_type=code

  • Authentication: Body

When credentials are created initially, everything works correctly and the credentials are returned in the response.However, after the token expires, we attempt to refresh it and update the credentials using the refresh token. While we receive the new access token and refresh token, updating them via the PATCH credential API results in no credentials returned in the response.

Patch API Request Sample

curl -X PATCH "https://your-n8n-instance.com/api/v1/credentials/{credentialID}" \
  -H "Content-Type: application/json" \
  -H "Cookie: n8n-auth=your-admin-session-cookie" \
  -d '{
    "id": "credential_id_here",
    "name": "My Credential Name",
    "type": "oAuth2Api",
    "data": {
      "clientId": "your_client_id",
      "clientSecret": "your_client_secret",
      "oAuthTokenData": {
        "access_token": "new_access_token",
        "refresh_token": "new_refresh_token",
        "expires_in": 3600,
        "token_type": "Bearer"
      }
    },
    "nodesAccess": [
      {
        "nodeType": "n8n-nodes-base.httpRequest"
      }
    ]
  }'

Issue: After executing the PATCH call, the updated credentials are not returned in the response, and it appears they are not being updated properly.

Request

Could you please help us understand:

  • Whether credential update using PATCH API for OAuth token refresh is supported?

  • If yes, is there a specific format or field required to ensure credentials are returned and stored correctly?

  • If not, is there an alternative recommended approach for refreshing OAuth tokens programmatically?

Thanks for your support!

Hi, although I can’t answer your original question about updating credentials manually I wonder why you need to do it in the first place.

I assume you use the standard OAuth2 credentials from n8n when making requests to Canva with an Http Request node? As far as I understand n8n takes care of refreshing the access token automatically when it expires.