enzostvs HF Staff commited on
Commit
2009fd5
·
1 Parent(s): 5b06170

fix prisma

Browse files
Files changed (1) hide show
  1. app/login/callback/page.tsx +13 -3
app/login/callback/page.tsx CHANGED
@@ -23,8 +23,18 @@ async function getAuth(code: string) {
23
  .clone()
24
  .json()
25
  .catch(() => ({}));
26
- console.log(response);
27
- return response;
 
 
 
 
 
 
 
 
 
 
28
  } catch (error) {
29
  console.log("error", error);
30
  return null;
@@ -39,7 +49,7 @@ export default async function LoginCallback({
39
  const profile = await getAuth(searchParams?.code as string);
40
  console.log(profile);
41
  return (
42
- <div className="pb-32">
43
  <p className="font-bold text-4xl text-white">LOGIN CALLBACK</p>
44
  {profile && JSON.stringify(profile, null, 2)}
45
  </div>
 
23
  .clone()
24
  .json()
25
  .catch(() => ({}));
26
+ const userRequest = await fetch("https://huggingface.co/oauth/userinfo", {
27
+ method: "GET",
28
+ headers: {
29
+ Authorization: `Bearer ${response.access_token}`,
30
+ },
31
+ });
32
+ const user = await userRequest
33
+ .clone()
34
+ .json()
35
+ .catch(() => ({}));
36
+ console.log(user);
37
+ return user;
38
  } catch (error) {
39
  console.log("error", error);
40
  return null;
 
49
  const profile = await getAuth(searchParams?.code as string);
50
  console.log(profile);
51
  return (
52
+ <div className="pb-32 text-white">
53
  <p className="font-bold text-4xl text-white">LOGIN CALLBACK</p>
54
  {profile && JSON.stringify(profile, null, 2)}
55
  </div>