fix: temporary adjustment for Salesforce OAuth2 template handling
parent
75659672bf
commit
6691427b37
|
@ -133,17 +133,33 @@ const oauthCallBack = async (req, res) => {
|
|||
client_id: crmOauth.crm.authentication.crmClientId,
|
||||
client_secret: crmOauth.crm.authentication.crmClientSecret,
|
||||
redirect_uri: process.env.URL_OAUTH_CALLBACK,
|
||||
|
||||
//remove this
|
||||
// refactor this. To salesforce only when using oauth2
|
||||
code_verifier: `gwkPueV2GSzkFvGFiHbNjpRuq_XBEGBsihM59pMaiFalZrOQ_7J4hgtBR8GIbLHutcuUwba2k0xeKhD8ELjWEswE3xv-H2e6Jh8EOwOccj2i_rYPUlMGdPDqpuRs8D3w`,
|
||||
code: `${code.split('%')[0]}`
|
||||
//
|
||||
|
||||
//enable this
|
||||
// code
|
||||
code
|
||||
}
|
||||
|
||||
// Refactor this. This is for salesforce only oauth2 that need a code_verifier. Try to find another
|
||||
// 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: `${code.split('%')[0]}`
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
|
||||
|
||||
|
||||
// Exchange the authorization code for an access token and refresh token
|
||||
await exchangeForTokens(crmOauth, authCodeProof)
|
||||
|
||||
|
|
Loading…
Reference in New Issue