Skip to content

Added port#135

Closed
Revadike wants to merge 6 commits into
levz0r:masterfrom
Revadike:patch-1
Closed

Added port#135
Revadike wants to merge 6 commits into
levz0r:masterfrom
Revadike:patch-1

Conversation

@Revadike
Copy link
Copy Markdown
Contributor

Port 80 is often used by other (essential) processes, making the current form of the library unusable for some people. This PR will make it configurable.

@Revadike
Copy link
Copy Markdown
Contributor Author

(In case you were wondering, I picked port 32019, because it is the start month of this project ;) )

Copy link
Copy Markdown
Owner

@levz0r levz0r left a comment

Choose a reason for hiding this comment

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

Review

Good feature - port 80 requires root privileges on Unix and blocks many users. Changing default to 32019 is a sensible choice.

Bugs Found 🐛

1. Assignment instead of argument passing (3 occurrences)

// gmail-tester.js:192 - BUG
return await _get_recent_email(credentials, token, options, port = 32019);
//                                                         ^^^^^^^^^^^^
// Should be just: port

// gmail-tester.js:209 - BUG  
const oAuth2Client = await gmail.authorize(credentials, token, port = 32019);
// Should be just: port

// gmail.js:31 - BUG
const newOAuth2Client = await get_new_token(oAuth2Client, token, port = 32019);
// Should be just: port

These are assignments (port = 32019), not parameter passing. This always passes 32019 regardless of what port value was passed in, breaking the feature.

2. Inconsistent defaults

  • oauth2.js defaults to port = 80
  • All other files default to port = 32019

Should be consistent (32019 everywhere).

Suggested Fix

// gmail-tester.js:192
- return await _get_recent_email(credentials, token, options, port = 32019);
+ return await _get_recent_email(credentials, token, options, port);

// gmail-tester.js:209
- const oAuth2Client = await gmail.authorize(credentials, token, port = 32019);
+ const oAuth2Client = await gmail.authorize(credentials, token, port);

// gmail.js:31
- const newOAuth2Client = await get_new_token(oAuth2Client, token, port = 32019);
+ const newOAuth2Client = await get_new_token(oAuth2Client, token, port);

// libs/oauth2.js:35
- async function authenticate(oauth2Client, scopes, tokensFile, port = 80) {
+ async function authenticate(oauth2Client, scopes, tokensFile, port = 32019) {

Once these are fixed, this PR is good to merge! 👍

@levz0r
Copy link
Copy Markdown
Owner

levz0r commented Dec 4, 2025

Thank you for the contribution! This PR has been superseded by #149 which includes your changes along with bug fixes, tests, and documentation updates.

@levz0r levz0r closed this Dec 4, 2025
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