feat: Implement createAuthLink mutation

This commit is contained in:
Faruk AYDIN
2021-10-14 15:17:58 +02:00
committed by Ali BARIN
parent 7f17420ae0
commit bdd0843d94
11 changed files with 130 additions and 3 deletions

View 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);
}
}

View File

@@ -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}"
}
]
}
]
}