yeah im using dev env and i using free plan as of now.
i am able to connect to google drive but i want to get that Oauth token from pipedream so i can open the picker
“use client”;
import { Button } from “@/components/ui/button”;
import { createFrontendClient } from “@pipedream/sdk/browser”;
import { useEffect, useState } from “react”;
const external_user_id = “65900b51f516229bb1a84de4”;
export default function PipedreamPage() {
const [token, setToken] = useState<string | null>(null);
useEffect(() => {
async function fetchToken() {
const res = await fetch(“/api/pd”, {
method: “POST”,
body: JSON.stringify({ external_user_id }),
headers: {
“Content-Type”: “application/json”,
},
});
console.log("res =>", res);
if (res.ok) {
const { token } = await res.json();
console.log("token =>", token);
setToken(token);
} else {
console.error("Failed to fetch token");
}
}
fetchToken();
}, );
const pd = createFrontendClient({
externalUserId: external_user_id,
});
console.log(“pd ===>”, pd);
function connectAccount() {
if (!token) return;
pd.connectAccount({
app: "google_drive",
// oauthAppId: process.env.NEXT_PUBLIC_API_KEY, // replace or remove this
token,
onSuccess: (data) => {
debugger;
console.log(":white_check_mark: Full onSuccess data:", data);
const { id: accountId } = data;
console.log(`Account successfully connected: ${accountId}`);
},
});
}
return (
Connect your account
);
}