Registry / auth-security / node-red-contrib-oauth2

node-red-contrib-oauth2

JSON →
library6.2.1jsnpmunverified

The `node-red-contrib-oauth2` package provides a specialized Node-RED node designed to streamline OAuth2 authentication flows within Node-RED environments. Its primary function is to facilitate the acquisition of access tokens from an OAuth2 server, which can then be seamlessly integrated into subsequent Node-RED nodes for making authenticated API requests. The current stable version is 6.2.1, with recent updates in May 2024, indicating an active development lifecycle and consistent release cadence. Notable features in recent versions include enhanced support for the OAuth2 implicit flow and a configurable option to force token refreshes. This node differentiates itself by abstracting complex OAuth2 mechanics into a visually configurable component within the Node-RED visual programming paradigm, supporting both static and dynamic credential management across various OAuth2 grant types, including Authorization Code, Client Credentials, Password, and Implicit flows.

npm install node-red-contrib-oauth2
INSTALL
IMPORT
SIG · NODE-RED-CONTRIB-O
N
node-red-contrib-oauth2
auth-securityjavascriptv6.2.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

node-red-contrib-oauth2 package
npm install node-red-contrib-oauth2
import { oauth2 } from 'node-red-contrib-oauth2'
Node-RED nodes are installed via npm or the Palette Manager into your Node-RED user directory, making them available in the Node-RED editor palette. They are not imported directly into JavaScript files in a traditional sense.
OAuth2 Node Type
Drag and drop the 'oauth2' node from the Node-RED editor palette onto your flow.
Once the package is installed, the 'oauth2' node type becomes available in the Node-RED editor palette, typically found under categories like 'network' or 'security'. Node functionality is configured visually within the editor.
Node Configuration
Configure the 'oauth2' node's properties (Client ID, Secret, Authorization URL, Token URL, Grant Type, Scopes, etc.) within its dialog box in the Node-RED editor.
Version 6.0.0 introduced new configuration options such as `access_type`, `response_type`, and `prompt` for enhanced OAuth2 flow flexibility, particularly for the implicit grant type. Version 6.2.1 added a 'Force Token Refresh' checkbox to the configuration.

This Node-RED flow demonstrates various OAuth2 grant types (Authorization Code, Client Credentials, Password) and how to manage token refresh. It provides a visual representation of obtaining and utilizing access tokens within a Node-RED environment for authenticated API requests.

[ {"id":"d15d33a4fa9a8ad9","type":"tab","label":"node-red-contrib-oauth2","disabled":false,"info":"","env":[]}, {"id":"7e1a2f9059f99060","type":"group","z":"d15d33a4fa9a8ad9","g":"368ef084fe6b53de","name":"REFRESH","style":{"label":true,"stroke":"#7f7f7f","color":"#000000","fill":"#bfdbef"},"nodes":["d1ba341040cea0c3","aa24d69faa1640cd","efd1a2a910ca1051","a8fca004e704e071","9e9332c792dbdc01","7f22873286146e83"],"x":76,"y":499,"w":1210,"h":208}, {"id":"7f22873286146e83","type":"group","z":"d15d33a4fa9a8ad9","g":"7e1a2f9059f99060","name":"via HTTP REQUEST","style":{"label":true},"nodes":["64d9243f.b7be7c","31727a2c.05a026","4030c52c.c2c29c","3b67977c.a53c08"],"x":102,"y":599,"w":1158,"h":82}, {"id":"54025cb0a19e0f14","type":"group","z":"d15d33a4fa9a8ad9","g":"368ef084fe6b53de","name":"Client Credentials","style":{"label":true,"stroke":"#a4a4a4","color":"#ffffff","fill":"#3f93cf"},"nodes":["10de26226e66ea9e","147aae5c70a7eecb","1e2169485cd2be43","ca6a8cddea946ab2","c6d4eb5c867902eb","d7a2041ef2683870","3f5a09c4fc8e769f"],"x":74,"y":179,"w":1212,"h":142}, {"id":"f37b3410d0e03c57","type":"group","z":"d15d33a4fa9a8ad9","g":"368ef084fe6b53de","name":"Authorization Code","style":{"label":true,"fill":"#3f93cf","color":"#ffffff"},"nodes":["8bd177259bc473f4","ee86852f62926632","d340377991d2d9b9","9e4d3edfde1766b9"],"x":74,"y":59,"w":1212,"h":82}, {"id":"a783ce686ac81a0c","type":"group","z":"d15d33a4fa9a8ad9","g":"368ef084fe6b53de","name":"Password","style":{"label":true,"fill":"#3f93cf","color":"#ffffff"},"nodes":["5ff7fb2616706080","8eadc61e4e5b4ac2","d857d0bc3e90d394","95745c4253c151f0","dcbde702eae7191d","d6a9695a923ab18b","c5da03044bdca6f1"],"x":74,"y":339,"w":1212,"h":142}, {"id":"368ef084fe6b53de","type":"group","z":"d15d33a4fa9a8ad9","name":"Grant Type","style":{"label":true,"fill":"#bfc7d7","color":"#0070c0"},"nodes":["7e1a2f9059f99060","54025cb0a19e0f14","f37b3410d0e03c57","a783ce686ac81a0c"],"x":48,"y":33,"w":1264,"h":700}, {"id":"ee86852f62926632","type":"oauth2","z":"d15d33a4fa9a8ad9","g":"f37b3410d0e03c57"} ]
Debug
Known issues
breakingVersion 6.0.0 introduced significant changes by adding comprehensive support for the OAuth2 implicit flow and new configuration fields (`access_type`, `response_type`, `prompt`). While designed for enhanced flexibility, existing flows utilizing older grant types should be thoroughly reviewed and potentially reconfigured to ensure continued compatibility and correct behavior, as default behaviors or implicit expectations might have shifted.
fix
After upgrading to v6.0.0 or later, review and reconfigure existing OAuth2 nodes, paying close attention to the new `access_type`, `response_type`, and `prompt` options if applicable. Thoroughly test all affected Node-RED flows.
affects: >=6.0.0
gotchaEnvironments with strict TLS policies or older Node.js versions might encounter 'DEPTH_ZERO_SELF_SIGNED_CERT' errors when the OAuth2 node attempts to connect to servers using self-signed certificates or specific proxy configurations.
fix
Upgrade `node-red-contrib-oauth2` to version 4.1.5 or newer, which includes a fix addressing this certificate validation issue. If the problem persists, ensure your Node.js environment's trust store includes the Certificate Authority for the OAuth2 server, or (with caution) temporarily disable TLS certificate validation for testing.
affects: <4.1.5
gotchaOAuth2 configurations are highly sensitive to precise URL matching (authorization, token, redirect URIs), correct client IDs, client secrets, and scope definitions. Any mismatch or misconfiguration will typically lead to authentication failures.
fix
Carefully verify all OAuth2 configuration parameters (Client ID, Client Secret, Authorization URL, Token URL, Redirect URI, Scopes) against the official documentation of your OAuth2 provider. Ensure the Redirect URI configured in Node-RED is exactly registered with your provider.
affects: *
Errors
Common errors & fixes
Error: self signed certificate in certificate chain
Node.js environment failing to validate the TLS certificate presented by the OAuth2 server, often due to a self-signed certificate or a missing Certificate Authority in the system's trust store.
fix
Upgrade `node-red-contrib-oauth2` to v4.1.5 or newer. If the issue persists, ensure your Node.js environment trusts the certificate authority that signed the OAuth2 server's certificate or explicitly add it. In development, setting `NODE_TLS_REJECT_UNAUTHORIZED=0` can bypass this, but is not recommended for production.
Node-RED 'oauth2' node not found in palette
The `node-red-contrib-oauth2` package was either not successfully installed or Node-RED requires a restart to recognize and load newly installed nodes.
fix
Confirm the package is installed by running `npm install node-red-contrib-oauth2` in your Node-RED user directory (`~/.node-red`) or by using the Node-RED Palette Manager. After installation, restart your Node-RED instance to refresh the editor's palette.
"invalid_client" or "unauthorized_client" in OAuth2 response
Incorrect client ID, client secret, or an unsupported/misconfigured grant type being used when the Node-RED OAuth2 node attempts to request a token from the OAuth2 server.
fix
Verify that the Client ID and Client Secret configured in the OAuth2 node are correct and match those registered with your OAuth2 provider. Also, ensure the chosen Grant Type (e.g., Client Credentials, Authorization Code, Password) is supported and correctly configured on both the Node-RED node and the OAuth2 server.
"redirect_uri_mismatch" in OAuth2 response
The redirect URI specified in the Node-RED OAuth2 node configuration does not precisely match one of the redirect URIs registered with the OAuth2 provider.
fix
Update the redirect URI in the OAuth2 node's configuration to exactly match one of the URIs registered and allowed by your OAuth2 provider. Pay close attention to the protocol (HTTP/HTTPS), hostname, port, and path, as these must be identical.
Upgrade
Version history
6.2.1latest on npm
Audit
Dependencies
node-redrequiredThis package provides a node for the Node-RED runtime environment.
noderequiredNode-RED and its nodes require a compatible Node.js version.
Agent activity
52 hits · last 30 days
node
50
Bingbot
1
OpenAI (training)
1
Resources
node-red-contrib-oauth2 — npm install node-red-contrib-oauth2 · libregistry