-
Notifications
You must be signed in to change notification settings - Fork 7
Add custom scopes in CreateAuthURL via PKCEConfig #20
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
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR enables custom OAuth scopes when creating authorization URLs in the onelogin-node-sdk. Previously, the library hardcoded the openid scope with no mechanism to add additional scopes needed for custom application parameters.
Key Changes:
- Adds optional
scopesarray parameter toPKCEConfiginterface - Removes hardcoded
QUERYPARAM_SCOPEconstant - Constructs scope query parameter dynamically, appending custom scopes after required
openidscope
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let queryParams = [ | ||
| `code_challenge=${codeChallenge}`, `client_id=${clientID}`, `redirect_uri=${redirectURL}`, | ||
| QUERYPARAM_CODE_CHALLENGE_METHOD, QUERYPARAM_RESPONSE_TYPE, QUERYPARAM_SCOPE | ||
| QUERYPARAM_CODE_CHALLENGE_METHOD, QUERYPARAM_RESPONSE_TYPE, `scope=openid${scopes ? ` ${scopes.join(" ")}` : ''}` |
Copilot
AI
Nov 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inline scope string construction is complex and hard to read. Consider extracting this logic into a separate method like _buildScopeParam(scopes?: Array<string>): string that constructs the scope parameter with 'openid' as the base and appends custom scopes if provided.
| interface PKCEConfig { | ||
| redirectURL: string, | ||
| clientID: string | ||
| clientID: string, |
Copilot
AI
Nov 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The scopes property lacks documentation explaining its purpose and that 'openid' is automatically included. Add a JSDoc comment to clarify that this array should contain additional scopes beyond 'openid', which is always present by default.
| clientID: string, | |
| clientID: string, | |
| /** | |
| * Additional scopes to request during authentication. | |
| * 'openid' is always included by default; specify only extra scopes here. | |
| */ |
When using the onelogin-node-sdk library to integrate oneLogin to our product we ended up with a situation where we needed to add scopes to get access to custom parameters that our application in oneLogin includes. but the library in its current state uses only the
openidscope with no way of adding more.This change allows the library to set custom scopes via the
Configuremethod of apkceobject. these scopes are added after theopenidscope (because that is a required scope).