feat(flickr): add authentication

This commit is contained in:
Ali BARIN
2022-10-21 01:33:40 +02:00
parent 05075fc1c4
commit 71d6a57cdc
19 changed files with 380 additions and 814 deletions

View File

@@ -0,0 +1,26 @@
import { IGlobalVariable } from '@automatisch/types';
import { URLSearchParams } from 'url';
const verifyCredentials = async ($: IGlobalVariable) => {
try {
const response = await $.http.post(
`/oauth/access_token?oauth_verifier=${$.auth.data.oauthVerifier}&oauth_token=${$.auth.data.accessToken}`,
null
);
const responseData = Object.fromEntries(new URLSearchParams(response.data));
await $.auth.set({
consumerKey: $.auth.data.consumerKey,
consumerSecret: $.auth.data.consumerSecret,
accessToken: responseData.oauth_token,
accessSecret: responseData.oauth_token_secret,
userId: responseData.user_nsid,
screenName: responseData.fullname,
});
} catch (error) {
throw new Error(error.response.data);
}
};
export default verifyCredentials;