mirror of
https://github.com/n8n-io/n8n.git
synced 2026-10-17 05:29:44 +02:00
fix(X (Formerly Twitter) Node): Update OAuth2 and API endpoints to x.com (#32699)
This commit is contained in:
parent
3ee502b301
commit
8ac5a60616
|
|
@ -43,13 +43,13 @@ export class TwitterOAuth2Api implements ICredentialType {
|
|||
displayName: 'Authorization URL',
|
||||
name: 'authUrl',
|
||||
type: 'hidden',
|
||||
default: 'https://twitter.com/i/oauth2/authorize',
|
||||
default: 'https://x.com/i/oauth2/authorize',
|
||||
},
|
||||
{
|
||||
displayName: 'Access Token URL',
|
||||
name: 'accessTokenUrl',
|
||||
type: 'hidden',
|
||||
default: 'https://api.twitter.com/2/oauth2/token',
|
||||
default: 'https://api.x.com/2/oauth2/token',
|
||||
},
|
||||
{
|
||||
displayName: 'Scope',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
import { TwitterOAuth2Api } from '../TwitterOAuth2Api.credentials';
|
||||
|
||||
describe('TwitterOAuth2Api Credential', () => {
|
||||
const credential = new TwitterOAuth2Api();
|
||||
|
||||
it('should have correct credential metadata', () => {
|
||||
expect(credential.name).toBe('twitterOAuth2Api');
|
||||
expect(credential.extends).toEqual(['oAuth2Api']);
|
||||
|
||||
const authUrlProperty = credential.properties.find((p) => p.name === 'authUrl');
|
||||
expect(authUrlProperty?.default).toBe('https://x.com/i/oauth2/authorize');
|
||||
|
||||
const accessTokenUrlProperty = credential.properties.find((p) => p.name === 'accessTokenUrl');
|
||||
expect(accessTokenUrlProperty?.default).toBe('https://api.x.com/2/oauth2/token');
|
||||
});
|
||||
|
||||
it('should use PKCE grant type', () => {
|
||||
const grantTypeProperty = credential.properties.find((p) => p.name === 'grantType');
|
||||
expect(grantTypeProperty?.type).toBe('hidden');
|
||||
expect(grantTypeProperty?.default).toBe('pkce');
|
||||
});
|
||||
|
||||
it('should use header authentication', () => {
|
||||
const authenticationProperty = credential.properties.find((p) => p.name === 'authentication');
|
||||
expect(authenticationProperty?.type).toBe('hidden');
|
||||
expect(authenticationProperty?.default).toBe('header');
|
||||
});
|
||||
|
||||
it('should default scope to the full scope list', () => {
|
||||
const scopeProperty = credential.properties.find((p) => p.name === 'scope');
|
||||
expect(scopeProperty?.type).toBe('hidden');
|
||||
expect(scopeProperty?.default).toBe(
|
||||
'tweet.read users.read tweet.write tweet.moderate.write users.read follows.read follows.write offline.access like.read like.write dm.write dm.read list.read list.write',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
@ -24,7 +24,7 @@ export async function twitterApiRequest(
|
|||
method,
|
||||
body,
|
||||
qs,
|
||||
url: uri || `https://api.twitter.com/2${resource}`,
|
||||
url: uri || `https://api.x.com/2${resource}`,
|
||||
json: true,
|
||||
};
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ describe('Test Twitter Request Node', () => {
|
|||
};
|
||||
|
||||
beforeAll(() => {
|
||||
const baseUrl = 'https://api.twitter.com/2';
|
||||
const baseUrl = 'https://api.x.com/2';
|
||||
//GET
|
||||
nock(baseUrl).get('/users/me').reply(200, meResult);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user