import {data} from '../wwwroot/core/appData.js';
import promptSync from 'prompt-sync';



const userData = await generate();
console.log(userData);
const newUserData = await renew(userData)

console.log(newUserData);

async function generate(){
    console.log("Testing token generation...")

    const url = data.instagramTokenManager.getOauthUrl();

    console.log("Go to this url : \n" + url);

    const prompt = promptSync();
    const code = prompt('Enter generated code : ');

    return await data.instagramTokenManager.generate(code)
}

async function renew(userData){
    console.log("Testing token refresh...")

    const res = await data.instagramTokenManager.renew(userData);

    console.log(res)
}