Agent Authentication
Learn about the authentication solution designed for AI agents
Integration
Connection
Last updated
Learn about the authentication solution designed for AI agents
Last updated
touch integration.tsimport { App, LangchainToolkit } from 'vity-toolkit';
import { StorageProvider } from 'vity-toolkit/src/storage-providers';
const toolkit = new LangchainToolkit({
appPrivateKey: "<wallet-private-key>", // PASTE A WALLET'S PRIVATE KEY
storageProvider: StorageProvider.PINATA
});
// 1. First get the expected params for the integration
// Get the expected params for the integration and fill in the required values
// const expectedParams = toolkit.getExpectedParamsForIntegration({ app: App.REDDIT });
// console.log(expectedParams);
// You will get this params from the console log
const params = {
CLIENT_ID: "",
CLIENT_SECRET: "",
}
params.CLIENT_ID = process.env.REDDIT_CLIENT_ID!;
params.CLIENT_SECRET = process.env.REDDIT_CLIENT_SECRET!;
// 2. Check if the integration already exists, pass the params to the isIntegration method
const iDetails = await toolkit.isIntegration({ app: App.REDDIT }); // The app you want to integrate
if (iDetails.success) {
console.log("Integration already exists!");
} else {
// Initiate the integration
await toolkit.appIntegration({
app: App.REDDIT,
authData: params,
})
}export REDDIT_CLIENT_ID=
export REDDIT_CLIENT_SECRET=
export PINATA_JWT=
export PINATA_GATEWAY=npm run integration.tstouch connection.tsimport { App, LangchainToolkit } from 'vity-toolkit';
import { AuthType } from 'vity-toolkit/src/sdk/types';
import { StorageProvider } from 'vity-toolkit/src/storage-providers';
const toolkit = new LangchainToolkit({
appPrivateKey: "<app-wallet-private-key>", // This should be same private key which you gave in INTEGRATION process
userPrivateKey: "<user-wallet-private-key>",
storageProvider: StorageProvider.PINATA
});
// 1. First get the expected params for the integration
// Get the expected params for the integration and fill in the required values
// const expectedParams = toolkit.getExpectedParamsForConnection({ app: App.REDDIT, type: AuthType.PASSWORD_BASED_AUTH });
// console.log(expectedParams);
// You will get this params from the console log
const params = {
USERNAME: "",
PASSWORD: "",
}
params.USERNAME = process.env.REDDIT_USERNAME!;
params.PASSWORD = process.env.REDDIT_PASSWORD!;
// 2. Check if the integration already exists, pass the params to the isIntegration method
const iDetails = await toolkit.isConnection({ app: App.REDDIT }); // The app you want to integrate
if (iDetails.success) {
console.log("Connection already exists!");
} else {
// Initiate the integration
await toolkit.initiateAppConnection({
app: App.REDDIT,
type: AuthType.PASSWORD_BASED_AUTH,
authData: params,
})
}export PINATA_JWT=
export PINATA_GATEWAY=npm run connection.tsimport { VityToolKit, Action } from "vity-toolkit";
const toolkit = new VityToolKit({
appPrivateKey: "<app-wallet-private-key>",
userPrivateKey: "<user-wallet-private-key>",
});
// 1. Get expected params for an action
// const expectedParams = toolKit.getInputParamsForAction({ action: Action.REDDIT_FILTER });
// console.log(expectedParams);
// 2. Get expected params for executing the action
const params = {
subreddit: "python",
query: ["fastapi"],
sort: "new",
limit: 1,
time: "all",
}
const result = await toolKit.executeAction({ action: Action.REDDIT_FILTER, inputParams: params });
console.log(result.data);