LocalWebAgent / js /oauth-callback.js
ereniko's picture
v0.8.2: Hugging Face sign-in from the embedded Space page, sturdier callback
5d3283b unverified
Raw History Blame Contribute Delete
595 Bytes
// Runs in oauth.html, the page Hugging Face redirects the sign-in popup to.
import { completeSignIn } from "./hf-auth.js";
const title = document.getElementById("title");
const msg = document.getElementById("msg");
try {
const r = await completeSignIn();
title.textContent = `Signed in${r.name ? ` as ${r.name}` : ""}`;
title.className = "ok";
msg.textContent = "You can close this window and go back to LocalWebAgent.";
setTimeout(() => window.close(), 700);
} catch (err) {
title.textContent = "Sign-in didn't work";
title.className = "bad";
msg.textContent = err.message;
}