Vaibhavs10 commited on
Commit
f74c3fb
·
1 Parent(s): 649d64c
Files changed (1) hide show
  1. index.html +14 -2
index.html CHANGED
@@ -128,6 +128,10 @@
128
  let isGenerating = false;
129
  let messageCount = 0;
130
 
 
 
 
 
131
  // Initialize
132
  document.addEventListener('DOMContentLoaded', async () => {
133
  await processRedirect();
@@ -185,7 +189,12 @@
185
  async function handleLogin() {
186
  try {
187
  // Redirect user to Hugging Face OAuth page
188
- const url = await oauthLoginUrl();
 
 
 
 
 
189
  window.location.href = url;
190
  } catch (error) {
191
  console.error("Login redirect error:", error);
@@ -350,7 +359,10 @@
350
  // Handle OAuth redirect result
351
  async function processRedirect() {
352
  try {
353
- const oauthResult = await oauthHandleRedirectIfPresent();
 
 
 
354
  if (oauthResult) {
355
  const token = oauthResult.accessToken;
356
  const info = oauthResult.userInfo || {};
 
128
  let isGenerating = false;
129
  let messageCount = 0;
130
 
131
+ // ---- OAuth configuration ----
132
+ const CLIENT_ID = document.querySelector('meta[name="hf-client-id"]')?.content;
133
+ const REDIRECT_URI = window.location.origin + window.location.pathname;
134
+
135
  // Initialize
136
  document.addEventListener('DOMContentLoaded', async () => {
137
  await processRedirect();
 
189
  async function handleLogin() {
190
  try {
191
  // Redirect user to Hugging Face OAuth page
192
+ const url = await oauthLoginUrl({
193
+ clientId: CLIENT_ID,
194
+ redirectUri: REDIRECT_URI,
195
+ // default scopes: openid profile; add inference-api so we can run models
196
+ scopes: ['openid','profile','inference-api']
197
+ });
198
  window.location.href = url;
199
  } catch (error) {
200
  console.error("Login redirect error:", error);
 
359
  // Handle OAuth redirect result
360
  async function processRedirect() {
361
  try {
362
+ const oauthResult = await oauthHandleRedirectIfPresent({
363
+ clientId: CLIENT_ID,
364
+ redirectUri: REDIRECT_URI
365
+ });
366
  if (oauthResult) {
367
  const token = oauthResult.accessToken;
368
  const info = oauthResult.userInfo || {};