Options. See InitInstagramAuthOptions.
Object with GET (route handler) and getRefreshedAccessToken (refreshes a long-lived token).
// app/api/(auth)/instagram/route.ts
import { initInstagramAuth } from "naystack/auth";
export const { GET, getRefreshedAccessToken } = initInstagramAuth({
onUser: async (igUser, appUserId, accessToken) => {
await saveInstagramUser(appUserId, igUser, accessToken);
},
successRedirectURL: "/dashboard",
errorRedirectURL: "/login",
refreshKey: process.env.REFRESH_KEY!,
});
Initializes Instagram OAuth. Returns a GET handler for the OAuth callback and a helper to refresh long-lived tokens.
Mount the GET handler on your Instagram auth route (e.g.
app/api/(auth)/instagram/route.ts).Requires env vars:
INSTAGRAM_CLIENT_ID,INSTAGRAM_CLIENT_SECRET,NEXT_PUBLIC_INSTAGRAM_AUTH_ENDPOINT.