Skip to content

fix(client-oauth2): 👻 ensure client_credentials flow follows RFC 6749 #16341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yonathan9669
Copy link

Summary

This PR ensures that the OAuth2 client credentials flow strictly follows RFC 6749 specifications, particularly section 4.4.3, which states that no refresh token should be included in the response.

Changes Made

  • Modified the ClientOAuth2Token class to handle the client credentials flow without expecting a refresh token
  • Updated the credentials flow implementation to properly handle token responses according to the spec
  • Added type safety to distinguish between different grant types

Testing

  • Verified that client credentials flow works without refresh tokens
  • Confirmed that token refresh attempts are made for client credentials grant type
  • Ensured backward compatibility with existing implementations

Related Issues

Additional Context

According to RFC 6749 Section 4.4.3, the client credentials flow should not return a refresh token. This change ensures compliance with the specification while maintaining backward compatibility with existing code.

Note: I have touched the minimum amount of code to solve the issue and preserve current behavior. I assume a better solution could be set in place but this would cover both scenarios for now.

Review Checklist

  • PR title and summary are descriptive
  • Code follows project style guidelines
  • Tests have been added/updated
  • Documentation has been updated if needed

- Update client credentials flow to comply with RFC 6749 section 4.4.3
- Remove refresh token from client credentials flow as per spec
- Maintain backward compatibility with existing implementations

Ref: https://community.n8n.io/t/oauth2-client-credentials-not-refreshing-expired-tokens/127129/6
@CLAassistant
Copy link

CLAassistant commented Jun 14, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cubic reviewed 4 files and found no issues. Review PR in cubic.dev.

@n8n-assistant n8n-assistant bot added the community Authored by a community member label Jun 14, 2025
@Joffcom
Copy link
Member

Joffcom commented Jun 14, 2025

Hey @yonathan9669,

Thanks for the PR, We have created "GHC-2537" as the internal reference to get this reviewed.

One of us will be in touch if there are any changes needed, in most cases this is normally within a couple of weeks but it depends on the current workload of the team.

@n8n-assistant n8n-assistant bot added the in linear Issue or PR has been created in Linear for internal review label Jun 14, 2025
@yonathan9669
Copy link
Author

Hey @Joffcom, thanks for your quick reply.

Awesome, I hope this small fix can help others facing similar issues with OAuth2 client credentials. 🤝

I'll be available to improve anything if it's required. There might be opportunities for further improvements, but I wanted to start with the most straightforward fix for the immediate issue.

Thanks a lot in advance for accepting my contribution to this amazing community 🙏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Authored by a community member in linear Issue or PR has been created in Linear for internal review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants