SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.
JavaScript a2aagentic-aiai-agentsdevtoolsmcp-clientn8n-alternativeno-codeopen-sourceorchestrationsmythosvisual-builder
fix: oauth template resolve err & add x oauth2 support
ahmedcoder01a578fd908d06
diff --git a/packages/app/src/backend/middlewares/oauthStrategy.mw.ts b/packages/app/src/backend/middlewares/oauthStrategy.mw.tsindex 682fad3f..5f5baeb1 100644--- a/packages/app/src/backend/middlewares/oauthStrategy.mw.ts+++ b/packages/app/src/backend/middlewares/oauthStrategy.mw.ts@@ -31,24 +31,23 @@ export const oauthStrategyInitialization = async (req, res, next) => {// Prepare the configurationlet config: any = { ...defaultConfig }; // Spread operator for shallow clone-// Use session-stored configuration instead of URL parametersif (isOAuth2 && req.session.oauth2Config) {const oauth2Config = req.session.oauth2Config;// Handle template variables in session-stored configconst configToProcess = { ...oauth2Config };- const mockReq = {- body: configToProcess,- _team: req._team,- session: req.session,- };-- const processedConfig = await replaceTemplateVariablesOptimized(mockReq).catch((error) => {- console.log('Template processing error for OAuth2:', error);- return configToProcess;+ const templateReq = Object.create(req, {+ body: { value: configToProcess, writable: true, enumerable: true },});+ const processedConfig = await replaceTemplateVariablesOptimized(templateReq).catch(+ (error) => {+ console.log('Template processing error for OAuth2:', error);+ return configToProcess;+ },+ );+config.clientID = processedConfig.clientID;config.clientSecret = processedConfig.clientSecret; // Safe from session + templates resolvedconfig.callbackURL = processedConfig.callbackURL;@@ -60,17 +59,17 @@ export const oauthStrategyInitialization = async (req, res, next) => {// Handle template variables in session-stored configconst configToProcess = { ...oauth1Config };- const mockReq = {- body: configToProcess,- _team: req._team,- session: req.session,- };+ const templateReq = Object.create(req, {+ body: { value: configToProcess, writable: true, enumerable: true },+ });//TODO : do we really need to handle template variables for oauth- const processedConfig = await replaceTemplateVariablesOptimized(mockReq).catch((error) => {- console.log('Template processing error for OAuth1:', error);- return configToProcess;- });+ const processedConfig = await replaceTemplateVariablesOptimized(templateReq).catch(+ (error) => {+ console.log('Template processing error for OAuth1:', error);+ return configToProcess;+ },+ );config.consumerKey = processedConfig.consumerKey;config.consumerSecret = processedConfig.consumerSecret; // Safe from session + templates resolved@@ -96,7 +95,6 @@ export const oauthStrategyInitialization = async (req, res, next) => {});}-// Derive callback URL when missingif (!config['callbackURL']) {try {diff --git a/packages/app/src/react/features/credentials/credentials-schema.json b/packages/app/src/react/features/credentials/credentials-schema.jsonindex 10626217..20401b01 100644--- a/packages/app/src/react/features/credentials/credentials-schema.json+++ b/packages/app/src/react/features/credentials/credentials-schema.json@@ -155,7 +155,7 @@},{"id": "twitter",- "name": "Twitter",+ "name": "X (OAuth 1.0a)","group": "oauth_connections_creds","auth_type": "oauth","description": "Connect to Twitter using OAuth 1.0a",@@ -203,6 +203,57 @@}]},+ {+ "id": "twitter_oauth2",+ "name": "X (OAuth 2.0)",+ "group": "oauth_connections_creds",+ "auth_type": "oauth2",+ "description": "Connect to Twitter/X using OAuth 2.0 with PKCE",+ "logo_url": "https://abs.twimg.com/favicons/twitter.3.ico",+ "docs_url": "https://developer.x.com/en/docs/authentication/oauth-2-0/authorization-code",+ "metadata": {+ "callback_path": "{{BASE_URL}}/oauth/twitter_oauth2/callback",+ "requires_callback": true+ },+ "fields": [+ {+ "key": "authorizationURL",+ "label": "Authorization URL",+ "type": "url",+ "required": true,+ "default": "https://twitter.com/i/oauth2/authorize"+ },+ {+ "key": "tokenURL",+ "label": "Token URL",+ "type": "url",+ "required": true,+ "default": "https://api.twitter.com/2/oauth2/token"+ },+ {+ "key": "clientID",+ "label": "Client ID",+ "type": "password",+ "required": true,+ "placeholder": "Enter your Twitter/X Client ID"+ },+ {+ "key": "clientSecret",+ "label": "Client Secret",+ "type": "password",+ "required": true,+ "placeholder": "Enter your Twitter/X Client Secret"+ },+ {+ "key": "scope",+ "label": "Scopes",+ "type": "textarea",+ "required": true,+ "default": "tweet.read tweet.write users.read offline.access",+ "placeholder": "Space-separated list of scopes"+ }+ ]+ },{"id": "custom_oauth2","name": "Custom OAuth2.0",diff --git a/packages/app/src/shared/helpers/oauth/oauth-services.json b/packages/app/src/shared/helpers/oauth/oauth-services.jsonindex 366e4907..3a2eed77 100644--- a/packages/app/src/shared/helpers/oauth/oauth-services.json+++ b/packages/app/src/shared/helpers/oauth/oauth-services.json@@ -51,6 +51,21 @@]}},+ "Twitter/X OAuth2": {+ "displayName": "Twitter/X OAuth2",+ "internalName": "twitter_oauth2",+ "type": "oauth2",+ "category": "predefined",+ "config": {+ "authorizationURL": "https://twitter.com/i/oauth2/authorize",+ "tokenURL": "https://api.twitter.com/2/oauth2/token",+ "scope": "tweet.read tweet.write users.read offline.access"+ },+ "callbackPath": "/oauth/twitter_oauth2/callback",+ "validation": {+ "required": ["clientID", "clientSecret", "authorizationURL", "tokenURL", "scope"]+ }+ },"Custom OAuth2.0": {"displayName": "Custom OAuth2.0","internalName": "oauth2",