Developing AI agents that securely communicate with external applications for users is challenging due to the complexity of managing different auth mechanisms like OAuth, API Key, Password based auth etc.
Let say, if you want to fetch about Solana from web, create a good content from that data and post it in twitter and reddit, all this using AI agents then this is very complex process as every apps have there own requires different authentication - OAuth, API Keys, etc. and the agent needs to work perfectly on you/your user's behalf. Seems an nightmare right??
Not any more, as this is where Vity Toolkit shines !!
Manage user-level authentication.
Works with multiple authentication methods.
Supports frameworks like Langchain, OpenAI, VercelAI (coming soon).
Securely encrypted authentication data, powered by Lit Protocol, ensures that only the legitimate account owner can access and use the tool.
Store data on your preferred platform, such as IPFS, AWS, or other options of your choice.
We take care of all the auth requirements for the app so that you can concentrate on developing AI agents that can transform the world .
Now that you understand how valuable Agent Authentication can be, let's explore how you can implement it. (Spoiler alert: It's super easy!)
Integration
This is an one-time process were you need authenticate your application/program. For that you usually need to provide client/consumer id and secret.
Here we are showing you an example, how you can integrate REDDIT app. I assume that you already
Paste this code and give a wallet's private key in toolkit
import { 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,
})
}
After doing this your app will be integrated. Now let's see how you/your users can connect with your app.
Connection
This is responsible for authenticating you or your users with your app. This process must be completed for each new user.
Here we are showing you an example, how you can setup for you/your user to connect with your integrated REDDIT app. I assume that you already
Have an reddit account.
1
Create a typescript file and open it in vs code
touch connection.ts
2
Paste this code and give required wallet's private key in toolkit
import { 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,
})
}