fix(X (Formerly Twitter) Node): Update OAuth2 and API endpoints to x.com (#32699)

This commit is contained in:
Srinjoy 2026-08-07 17:42:52 +05:30 committed by GitHub
parent 3ee502b301
commit 8ac5a60616
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 40 additions and 4 deletions

View File

@ -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',

View File

@ -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',
);
});
});

View File

@ -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 {

View File

@ -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);