
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
oauth-token-automation
Advanced tools
Zero-setup OAuth authorization code flow automation with browser automation
A minimal OAuth authorization code flow automation tool that handles the complete flow from user authentication to token retrieval in one click.
Configure your environment:
# Copy and edit the config file for your environment
cp config.dev.json config.myenv.json
Update configuration in config.myenv.json
:
{
"authentication_url": "https://your-auth-server.com/oauth/authorize",
"username": "your-username",
"password": "your-password",
"client_id": "your-client-id",
"scope": "read write",
"state": "random-state-string",
"response_type": "code",
"redirect_uri": "http://localhost:3000/callback",
"token_url": "https://your-auth-server.com/oauth/token",
"client_secret": "your-client-secret",
"timeout": 30000,
"headless": true,
"port": 3000
}
Run the automation:
# Using npx (automatically installs dependencies)
npx playwright install chromium
node oauth-automation.js --env=myenv
The tool automatically handles all dependencies for you:
# Just run directly - it will auto-install everything needed
node oauth-standalone.js --env=myenv
The first run will:
If you prefer to install dependencies manually:
# Install Playwright
npm install playwright
# Install browser (required for automation)
npx playwright install chromium
# Run with default dev environment
node oauth-automation.js --env=dev
# Run with production environment
node oauth-automation.js --env=prod
# Run with custom environment
node oauth-automation.js --env=staging
# Install dependencies first
npm setup
# Run with predefined scripts
npm run dev # Uses dev environment
npm run prod # Uses prod environment
Create config.{environment}.json
files for each environment:
config.dev.json
- Development environmentconfig.prod.json
- Production environmentconfig.staging.json
- Staging environmentParameter | Description | Required |
---|---|---|
authentication_url | OAuth authorization endpoint | ✅ |
username | User credentials for login | ✅ |
password | User credentials for login | ✅ |
client_id | OAuth client identifier | ✅ |
client_secret | OAuth client secret for token exchange | ✅ |
token_url | Token exchange endpoint | ✅ |
scope | Requested permissions | ✅ |
state | CSRF protection token | ✅ |
response_type | OAuth response type (usually "code") | ✅ |
redirect_uri | Callback URL for OAuth redirect | ✅ |
timeout | Browser timeout in milliseconds | ❌ |
headless | Run browser in headless mode | ❌ |
Different OAuth providers may have different HTML structures for their login pages. You can configure custom selectors for each environment:
{
// ...other config...
"selectors": {
"username": [
"input[name=\"j_username\"]",
"input[id=\"j_username\"]",
"#username",
"input[name=\"username\"]",
"input[type=\"email\"]"
],
"password": [
"input[name=\"j_password\"]",
"input[id=\"j_password\"]",
"#password",
"input[name=\"password\"]",
"input[type=\"password\"]"
],
"submit": [
"input[type=\"submit\"]",
"button[type=\"submit\"]",
"#submit",
".submit-btn",
"button:has-text(\"Sign In\")",
"button:has-text(\"Login\")"
]
}
}
How it works:
Common selector patterns:
input[name="username"]
, input[type="password"]
input[name="j_username"]
, input[name="j_password"]
The tool provides:
tokens.{environment}.json
Example output:
{
"access_token": "eyJhbGciOiJSUzI1NiIs...",
"refresh_token": "def50200f3a5c8b7e...",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "read write"
}
Browser automation fails:
"headless": false
)Callback not received:
Token exchange fails:
Set "headless": false
in your config to see the browser automation in action.
The tool automatically copies the access token to your system clipboard after successful OAuth completion:
After running the tool, you can immediately paste (Ctrl+V
/ Cmd+V
) the access token into:
curl -H "Authorization: Bearer <paste-here>"
)MIT
FAQs
Zero-setup OAuth authorization code flow automation with browser automation
The npm package oauth-token-automation receives a total of 20 weekly downloads. As such, oauth-token-automation popularity was classified as not popular.
We found that oauth-token-automation demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.