[GH-ISSUE #3784] [bug]: OAuth 2.0 implementation does not support authorization code flow with PKCE #1319

Closed
opened 2026-03-16 19:48:48 +03:00 by kerem · 8 comments
Owner

Originally created by @cmaune on GitHub (Jan 29, 2024).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/3784

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

As mentioned in the readme.md OIDC Access Token/PKCE should be supported.

Currently after filling up all necessary fields for OAuth 2.0 (OpenId Connect Discorvery URL, Authorization URL, Access Token URL, Client Id and Scope) a token request with "client_secret: undefinied" is send to the configured token endpoint.
But for PKCE the clientSecret is not needed.

This leads at least with Azure as an identity plaform to an error.

Further more the input validation only seems to kick off after a "browser" refresh.
When creating a new request and filling up all necessary fields for PKCE the request is send, after a browser refresh clicking the button "Generate token" leads to a warning "No client secret defined"

Possible Fix:

Steps to reproduce

  1. Go to "REST" Tab
  2. Click an "Authorization" for any Request
  3. Fill up OpenID Connect Discovery URL, Authorization URL, Access Token URL, Client Id and Scope
  4. Press "Generate Token"
  5. Look at the request made in dev-tools, this includes a client_secret=undefined.

Environment

Production

Version

Cloud

Originally created by @cmaune on GitHub (Jan 29, 2024). Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/3784 ### Is there an existing issue for this? - [X] I have searched the existing issues ### Current behavior As mentioned in the readme.md OIDC Access Token/PKCE should be supported. Currently after filling up all necessary fields for OAuth 2.0 (OpenId Connect Discorvery URL, Authorization URL, Access Token URL, Client Id and Scope) a token request with "client_secret: undefinied" is send to the configured token endpoint. But for PKCE the clientSecret is **not needed**. This leads at least with Azure as an identity plaform to an error. Further more the input validation only seems to kick off after a "browser" refresh. When creating a new request and filling up all necessary fields for PKCE the request is send, after a browser refresh clicking the button "Generate token" leads to a warning "No client secret defined" Possible Fix: - Remove the required check for client_secret: https://github.com/hoppscotch/hoppscotch/blob/main/packages/hoppscotch-common/src/helpers/oauth.ts#L263-L265 - Only pass client_secret as parameter when its set ( != undefined, empty, etc.): https://github.com/hoppscotch/hoppscotch/blob/main/packages/hoppscotch-common/src/helpers/oauth.ts#L278 ### Steps to reproduce 1. Go to "REST" Tab 2. Click an "Authorization" for any Request 3. Fill up OpenID Connect Discovery URL, Authorization URL, Access Token URL, Client Id and Scope 4. Press "Generate Token" 5. Look at the request made in dev-tools, this includes a client_secret=undefined. ### Environment Production ### Version Cloud
kerem 2026-03-16 19:48:48 +03:00
Author
Owner

@tonnico commented on GitHub (Feb 13, 2024):

Is there a workaround until the problem is fixed?

<!-- gh-comment-id:1942185184 --> @tonnico commented on GitHub (Feb 13, 2024): Is there a workaround until the problem is fixed?
Author
Owner

@aconstantin commented on GitHub (Feb 13, 2024):

Do you need any help here? Should we try to provide a fix? If yes, can you provide some guidance?

<!-- gh-comment-id:1942192965 --> @aconstantin commented on GitHub (Feb 13, 2024): Do you need any help here? Should we try to provide a fix? If yes, can you provide some guidance?
Author
Owner

@MarcelHoell commented on GitHub (Feb 29, 2024):

That fix would be pretty nice!

<!-- gh-comment-id:1970617096 --> @MarcelHoell commented on GitHub (Feb 29, 2024): That fix would be pretty nice!
Author
Owner

@StormicK commented on GitHub (Apr 18, 2024):

Are there any news about this topic?

<!-- gh-comment-id:2064282071 --> @StormicK commented on GitHub (Apr 18, 2024): Are there any news about this topic?
Author
Owner

@mkohns commented on GitHub (Apr 28, 2024):

Hi. I would like to follow up on this:

I am using Desktop App Version: Version 24.3.1-2 (20240423.091309)

When configuring "Authorization" Tab for a REST call to use OAuth2 with PKCE the "client_secret" seems to be mandatory. If you do not provide it - hoppscotch shows a toast message with validation error.

From my point of view the OAuth2 with PKCE for so called public clients should not have a secret provided.
This is due to the fact as the secret can not be stored securely in SPAs, Mobile Apps or Desktop Apps which does not have a backend for authentication.

If you try to provide an client secret - the Azure AD (now EntraID) also identifies this and responses an error:

{"error":"invalid_client","error_description":"AADSTS700025: Client is public so neither 'client_assertion' nor 'client_secret' should be presented}.

From my perspective the code change could look like this:

  1. make client_secret optional if PKCE is enabled:
    github.com/hoppscotch/hoppscotch@844eee0fa4/packages/hoppscotch-common/src/services/oauth/flows/authCode.ts (L33)

  2. only append client_secret if also provided by user:
    github.com/hoppscotch/hoppscotch@844eee0fa4/packages/hoppscotch-common/src/services/oauth/flows/authCode.ts (L206)

The rest looks great to me.

@amk-dev and @jamesgeorge007 seemed to implemented this great feature.
Could you please comment here?

<!-- gh-comment-id:2081381369 --> @mkohns commented on GitHub (Apr 28, 2024): Hi. I would like to follow up on this: I am using Desktop App Version: Version 24.3.1-2 (20240423.091309) When configuring "Authorization" Tab for a REST call to use OAuth2 with PKCE the "client_secret" seems to be mandatory. If you do not provide it - hoppscotch shows a toast message with validation error. From my point of view the OAuth2 with PKCE for so called public clients should not have a secret provided. This is due to the fact as the secret can not be stored securely in SPAs, Mobile Apps or Desktop Apps which does not have a backend for authentication. If you try to provide an client secret - the Azure AD (now EntraID) also identifies this and responses an error: `{"error":"invalid_client","error_description":"AADSTS700025: Client is public so neither 'client_assertion' nor 'client_secret' should be presented}.` From my perspective the code change could look like this: 1. make client_secret optional if PKCE is enabled: https://github.com/hoppscotch/hoppscotch/blob/844eee0fa4c0a5187a046f6b8c2c3fc3ed4ab4b6/packages/hoppscotch-common/src/services/oauth/flows/authCode.ts#L33 2. only append client_secret if also provided by user: https://github.com/hoppscotch/hoppscotch/blob/844eee0fa4c0a5187a046f6b8c2c3fc3ed4ab4b6/packages/hoppscotch-common/src/services/oauth/flows/authCode.ts#L206 The rest looks great to me. @amk-dev and @jamesgeorge007 seemed to implemented this great feature. Could you please comment here?
Author
Owner

@mkohns commented on GitHub (Apr 28, 2024):

I have set up the local dev environment for the hoppscotch desktop application and just uncommented the above lines for testing. I can confirm that the auth flow is then working as expected. Nice.

<!-- gh-comment-id:2081477859 --> @mkohns commented on GitHub (Apr 28, 2024): I have set up the local dev environment for the hoppscotch desktop application and just uncommented the above lines for testing. I can confirm that the auth flow is then working as expected. Nice.
Author
Owner

@liyasthomas commented on GitHub (Apr 28, 2024):

cc: @amk-dev can you follow-up this?

<!-- gh-comment-id:2081511127 --> @liyasthomas commented on GitHub (Apr 28, 2024): cc: @amk-dev can you follow-up this?
Author
Owner

@kbakeradi commented on GitHub (May 3, 2024):

cc: @amk-dev can you follow-up this?

I have set up the local dev environment for the hoppscotch desktop application and just uncommented the above lines for testing. I can confirm that the auth flow is then working as expected. Nice.
Could you submit a PR for this? I'll try to duplicate your success, but it might help to get this fix into the tool.

<!-- gh-comment-id:2093540566 --> @kbakeradi commented on GitHub (May 3, 2024): > cc: @amk-dev can you follow-up this? > I have set up the local dev environment for the hoppscotch desktop application and just uncommented the above lines for testing. I can confirm that the auth flow is then working as expected. Nice. Could you submit a PR for this? I'll try to duplicate your success, but it might help to get this fix into the tool.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#1319
No description provided.