fix: temporary adjustment for Salesforce OAuth2 template handling
parent
75659672bf
commit
6691427b37
|
@ -133,16 +133,32 @@ const oauthCallBack = async (req, res) => {
|
||||||
client_id: crmOauth.crm.authentication.crmClientId,
|
client_id: crmOauth.crm.authentication.crmClientId,
|
||||||
client_secret: crmOauth.crm.authentication.crmClientSecret,
|
client_secret: crmOauth.crm.authentication.crmClientSecret,
|
||||||
redirect_uri: process.env.URL_OAUTH_CALLBACK,
|
redirect_uri: process.env.URL_OAUTH_CALLBACK,
|
||||||
|
code
|
||||||
|
}
|
||||||
|
|
||||||
//remove this
|
// Refactor this. This is for salesforce only oauth2 that need a code_verifier. Try to find another
|
||||||
// refactor this. To salesforce only when using oauth2
|
// way of gettig the code without need the code_verifier
|
||||||
|
const rest = crmOauth.crm.crmRest
|
||||||
|
const salesforceUrls = rest.map(endpoint => {
|
||||||
|
const key = Object.keys(endpoint)[0]
|
||||||
|
const url = endpoint[key].request.url
|
||||||
|
|
||||||
|
if (url.includes("salesforce")) {
|
||||||
|
return `${key} URL: ${url}`
|
||||||
|
}
|
||||||
|
}).filter(Boolean)
|
||||||
|
|
||||||
|
if (salesforceUrls.find(url => url.includes('salesforce'))) {
|
||||||
|
authCodeProof = {
|
||||||
|
...authCodeProof, ...{
|
||||||
code_verifier: `gwkPueV2GSzkFvGFiHbNjpRuq_XBEGBsihM59pMaiFalZrOQ_7J4hgtBR8GIbLHutcuUwba2k0xeKhD8ELjWEswE3xv-H2e6Jh8EOwOccj2i_rYPUlMGdPDqpuRs8D3w`,
|
code_verifier: `gwkPueV2GSzkFvGFiHbNjpRuq_XBEGBsihM59pMaiFalZrOQ_7J4hgtBR8GIbLHutcuUwba2k0xeKhD8ELjWEswE3xv-H2e6Jh8EOwOccj2i_rYPUlMGdPDqpuRs8D3w`,
|
||||||
code: `${code.split('%')[0]}`
|
code: `${code.split('%')[0]}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
//
|
//
|
||||||
|
|
||||||
//enable this
|
|
||||||
// code
|
|
||||||
}
|
|
||||||
|
|
||||||
// Exchange the authorization code for an access token and refresh token
|
// Exchange the authorization code for an access token and refresh token
|
||||||
await exchangeForTokens(crmOauth, authCodeProof)
|
await exchangeForTokens(crmOauth, authCodeProof)
|
||||||
|
|
Loading…
Reference in New Issue