chore: Make createAuthLink mutation more generic
This commit is contained in:
@@ -21,8 +21,8 @@
|
||||
"dotenv": "^10.0.0",
|
||||
"express": "~4.16.1",
|
||||
"express-graphql": "^0.12.0",
|
||||
"flickr-sdk": "^3.10.0",
|
||||
"googleapis": "^89.0.0",
|
||||
"flickr-sdk": "3.10.0",
|
||||
"googleapis": "89.0.0",
|
||||
"graphql-type-json": "^0.3.2",
|
||||
"http-errors": "~1.6.3",
|
||||
"knex": "^0.95.11",
|
||||
|
@@ -34,8 +34,9 @@ export default class Flickr {
|
||||
const url = await this.oauthClient.authorizeUrl(oauthData.oauth_token, 'delete');
|
||||
|
||||
return {
|
||||
...oauthData,
|
||||
url,
|
||||
accessToken: oauthData.oauth_token,
|
||||
accessSecret: oauthData.oauth_token_secret,
|
||||
url: url,
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -23,7 +23,13 @@ export default class Twitter {
|
||||
const appFields = this.appData.fields.find((field: Field) => field.key == 'oAuthRedirectUrl')
|
||||
const callbackUrl = appFields.value;
|
||||
|
||||
return this.client.generateAuthLink(callbackUrl);
|
||||
const authLink = await this.client.generateAuthLink(callbackUrl);
|
||||
|
||||
return {
|
||||
url: authLink.url,
|
||||
accessToken: authLink.oauth_token,
|
||||
accessSecret: authLink.oauth_token_secret,
|
||||
}
|
||||
}
|
||||
|
||||
async verifyCredentials() {
|
||||
|
@@ -18,16 +18,14 @@ const createAuthLinkResolver = async (params: Params, req: RequestWithCurrentUse
|
||||
consumerKey: connection.data.consumerKey,
|
||||
consumerSecret: connection.data.consumerSecret
|
||||
});
|
||||
|
||||
const authLink = await appInstance.createAuthLink();
|
||||
|
||||
await connection.$query().patch({
|
||||
data: {
|
||||
...connection.data,
|
||||
url: authLink.url,
|
||||
accessToken: authLink.oauth_token,
|
||||
accessSecret: authLink.oauth_token_secret,
|
||||
},
|
||||
verified: authLink.oauth_callback_confirmed === 'true' ? true : false
|
||||
...authLink
|
||||
}
|
||||
})
|
||||
|
||||
return authLink;
|
||||
|
@@ -18,7 +18,8 @@ const verifyConnectionResolver = async (params: Params, req: RequestWithCurrentU
|
||||
const verifiedCredentials = await appInstance.verifyCredentials();
|
||||
|
||||
connection = await connection.$query().patchAndFetch({
|
||||
data: verifiedCredentials
|
||||
data: verifiedCredentials,
|
||||
verified: true
|
||||
})
|
||||
|
||||
return connection;
|
||||
|
Reference in New Issue
Block a user