mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(core): Fix OAuth1 callback token request (#14251)
This commit is contained in:
@@ -230,15 +230,11 @@ describe('OAuth1CredentialController', () => {
|
|||||||
});
|
});
|
||||||
jest.spyOn(Csrf.prototype, 'verify').mockReturnValueOnce(true);
|
jest.spyOn(Csrf.prototype, 'verify').mockReturnValueOnce(true);
|
||||||
nock('https://example.domain')
|
nock('https://example.domain')
|
||||||
.post('/oauth/access_token', {
|
.post('/oauth/access_token', 'oauth_token=token&oauth_verifier=verifier')
|
||||||
oauth_token: 'token',
|
|
||||||
oauth_verifier: 'verifier',
|
|
||||||
})
|
|
||||||
.once()
|
.once()
|
||||||
.reply(200, 'access_token=new_token');
|
.reply(200, 'access_token=new_token');
|
||||||
|
|
||||||
await controller.handleCallback(req, res);
|
await controller.handleCallback(req, res);
|
||||||
|
|
||||||
const dataCaptor = captor();
|
const dataCaptor = captor();
|
||||||
expect(credentialsRepository.update).toHaveBeenCalledWith(
|
expect(credentialsRepository.update).toHaveBeenCalledWith(
|
||||||
'1',
|
'1',
|
||||||
|
|||||||
@@ -118,10 +118,12 @@ export class OAuth1CredentialController extends AbstractOAuthController {
|
|||||||
const [credential, _, oauthCredentials] =
|
const [credential, _, oauthCredentials] =
|
||||||
await this.resolveCredential<OAuth1CredentialData>(req);
|
await this.resolveCredential<OAuth1CredentialData>(req);
|
||||||
|
|
||||||
const oauthToken = await axios.post<string>(oauthCredentials.accessTokenUrl, {
|
// Form URL encoded body https://datatracker.ietf.org/doc/html/rfc5849#section-3.5.2
|
||||||
oauth_token,
|
const oauthToken = await axios.post<string>(
|
||||||
oauth_verifier,
|
oauthCredentials.accessTokenUrl,
|
||||||
});
|
{ oauth_token, oauth_verifier },
|
||||||
|
{ headers: { 'content-type': 'application/x-www-form-urlencoded' } },
|
||||||
|
);
|
||||||
|
|
||||||
// Response comes as x-www-form-urlencoded string so convert it to JSON
|
// Response comes as x-www-form-urlencoded string so convert it to JSON
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user