feat: Implement createAuthLink mutation
This commit is contained in:
24
packages/backend/src/apps/twitter/index.ts
Normal file
24
packages/backend/src/apps/twitter/index.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import TwitterApi from 'twitter-api-v2';
|
||||
import App from '../../models/app';
|
||||
import Field from '../../types/field';
|
||||
|
||||
export default class Twitter {
|
||||
client: any
|
||||
appData: any
|
||||
|
||||
constructor(credentialsData: any) {
|
||||
this.client = new TwitterApi({
|
||||
appKey: credentialsData.consumerKey,
|
||||
appSecret: credentialsData.consumerSecret
|
||||
});
|
||||
|
||||
this.appData = App.findOneByName('twitter')
|
||||
}
|
||||
|
||||
async createAuthLink() {
|
||||
const appFields = this.appData.fields.find((field: Field) => field.key == 'oAuthRedirectUrl')
|
||||
const callbackUrl = appFields.value;
|
||||
|
||||
return this.client.generateAuthLink(callbackUrl);
|
||||
}
|
||||
}
|
@@ -12,7 +12,7 @@
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"readOnly": true,
|
||||
"value": "http://localhost:3000/sample",
|
||||
"value": "http://localhost:3001/app/twitter/connections/add",
|
||||
"placeholder": null,
|
||||
"description": "When asked to input an OAuth callback or redirect URL in Twitter OAuth, enter the URL above.",
|
||||
"docUrl": "https://automatisch.io/docs/twitter#oauth-redirect-url",
|
||||
@@ -84,6 +84,17 @@
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 2,
|
||||
"type": "mutation",
|
||||
"name": "createAuthLink",
|
||||
"fields": [
|
||||
{
|
||||
"name": "id",
|
||||
"value": "{response.credentialId}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Reference in New Issue
Block a user