mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 21:19:43 -08:00
Use instance URL for OAuth callback (#3560)
Use editor URL instead of webhook url for oauth connections
This commit is contained in:
parent
3ae6450f0b
commit
ff31b961b7
|
@ -18,7 +18,7 @@ import {
|
||||||
import { resolve as pathResolve } from 'path';
|
import { resolve as pathResolve } from 'path';
|
||||||
import querystring from 'querystring';
|
import querystring from 'querystring';
|
||||||
|
|
||||||
import { Db, ICredentialsDb, ResponseHelper, WebhookHelpers } from '..';
|
import { Db, ICredentialsDb, ResponseHelper } from '..';
|
||||||
import { RESPONSE_ERROR_MESSAGES } from '../constants';
|
import { RESPONSE_ERROR_MESSAGES } from '../constants';
|
||||||
import {
|
import {
|
||||||
CredentialsHelper,
|
CredentialsHelper,
|
||||||
|
@ -29,6 +29,7 @@ import { getLogger } from '../Logger';
|
||||||
import { OAuthRequest } from '../requests';
|
import { OAuthRequest } from '../requests';
|
||||||
import { externalHooks } from '../Server';
|
import { externalHooks } from '../Server';
|
||||||
import config from '../../config';
|
import config from '../../config';
|
||||||
|
import { getInstanceBaseUrl } from '../UserManagement/UserManagementHelper';
|
||||||
|
|
||||||
export const oauth2CredentialController = express.Router();
|
export const oauth2CredentialController = express.Router();
|
||||||
|
|
||||||
|
@ -109,7 +110,7 @@ oauth2CredentialController.get(
|
||||||
clientSecret: get(oauthCredentials, 'clientSecret', '') as string,
|
clientSecret: get(oauthCredentials, 'clientSecret', '') as string,
|
||||||
accessTokenUri: get(oauthCredentials, 'accessTokenUrl', '') as string,
|
accessTokenUri: get(oauthCredentials, 'accessTokenUrl', '') as string,
|
||||||
authorizationUri: get(oauthCredentials, 'authUrl', '') as string,
|
authorizationUri: get(oauthCredentials, 'authUrl', '') as string,
|
||||||
redirectUri: `${WebhookHelpers.getWebhookBaseUrl()}${restEndpoint}/oauth2-credential/callback`,
|
redirectUri: `${getInstanceBaseUrl()}${restEndpoint}/oauth2-credential/callback`,
|
||||||
scopes: split(get(oauthCredentials, 'scope', 'openid,') as string, ','),
|
scopes: split(get(oauthCredentials, 'scope', 'openid,') as string, ','),
|
||||||
state: stateEncodedStr,
|
state: stateEncodedStr,
|
||||||
};
|
};
|
||||||
|
@ -265,7 +266,7 @@ oauth2CredentialController.get(
|
||||||
clientSecret: get(oauthCredentials, 'clientSecret', '') as string | undefined,
|
clientSecret: get(oauthCredentials, 'clientSecret', '') as string | undefined,
|
||||||
accessTokenUri: get(oauthCredentials, 'accessTokenUrl', '') as string,
|
accessTokenUri: get(oauthCredentials, 'accessTokenUrl', '') as string,
|
||||||
authorizationUri: get(oauthCredentials, 'authUrl', '') as string,
|
authorizationUri: get(oauthCredentials, 'authUrl', '') as string,
|
||||||
redirectUri: `${WebhookHelpers.getWebhookBaseUrl()}${restEndpoint}/oauth2-credential/callback`,
|
redirectUri: `${getInstanceBaseUrl()}${restEndpoint}/oauth2-credential/callback`,
|
||||||
scopes: split(get(oauthCredentials, 'scope', 'openid,') as string, ','),
|
scopes: split(get(oauthCredentials, 'scope', 'openid,') as string, ','),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue