chore: Make createAuthLink mutation more generic

This commit is contained in:
Faruk AYDIN
2021-10-24 20:06:16 +02:00
committed by Ali BARIN
parent 81d5e6d17c
commit 8e91f1f7ed
6 changed files with 19 additions and 13 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -7530,7 +7530,7 @@ flatten@^1.0.2:
resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.3.tgz#c1283ac9f27b368abc1e36d1ff7b04501a30356b"
integrity sha512-dVsPA/UwQ8+2uoFe5GHtiBMu48dWLTdsuEd7CKGlZlD78r1TTWBvDuFaFGKCo/ZfEr95Uk56vZoX86OsHkUeIg==
flickr-sdk@^3.10.0:
flickr-sdk@3.10.0:
version "3.10.0"
resolved "https://registry.yarnpkg.com/flickr-sdk/-/flickr-sdk-3.10.0.tgz#87eb0221bc2a5380eacac328a0230a86555316d3"
integrity sha512-JBGWFYTE5xvm6oG34IEQL0TX7FFLuWWFcWjlv2wVeB6Gj7VybVeoOXSvIX35hG1FVUbJTrVYBJRgpbjGf3cl3A==
@@ -8017,7 +8017,7 @@ googleapis-common@^5.0.2:
url-template "^2.0.8"
uuid "^8.0.0"
googleapis@^89.0.0:
googleapis@89.0.0:
version "89.0.0"
resolved "https://registry.yarnpkg.com/googleapis/-/googleapis-89.0.0.tgz#03de7b1467c066d48b989f6a8384857ef6971e69"
integrity sha512-eH91BN+6R/Mp5uulrhKWGwKAbibfDNOIu1Oq8n12aFTiqb23/A9kVdRhituYVqhRqSWLr/kv1dpFbd6n+uN+7Q==