enzostvs HF Staff commited on
Commit
d04cadb
·
1 Parent(s): f7107ee

hf sign in

Browse files
Files changed (1) hide show
  1. app/login/callback/page.tsx +23 -20
app/login/callback/page.tsx CHANGED
@@ -7,33 +7,36 @@ async function getAuth(code: string) {
7
  `${process.env.OAUTH_CLIENT_ID}:${process.env.OAUTH_CLIENT_SECRET}`
8
  ).toString("base64")}`;
9
 
10
- // const request = await fetch("https://huggingface.co/oauth/token", {
11
- // method: "POST",
12
- // headers: {
13
- // "Content-Type": "application/x-www-form-urlencoded",
14
- // Authorization,
15
- // },
16
- // // send as Form data
17
- // body: new URLSearchParams({
18
- // grant_type: "authorization_code",
19
- // code,
20
- // redirect_uri: REDIRECT_URI,
21
- // }),
22
- // });
23
 
24
- // const response = await request
25
- // .clone()
26
- // .json()
27
- // .catch(() => ({}));
28
 
29
  // console.log(response);
30
  // if (!response.access_token) {
31
  // return response;
32
  // }
33
- // // @ts-ignore
34
  // cookies.set("access_token", response.access_token, {});
35
 
36
- return null;
 
 
 
37
  } catch (error) {
38
  return error;
39
  }
@@ -48,7 +51,7 @@ export default async function LoginCallback({
48
  return (
49
  <div className="pb-32 text-white">
50
  <p className="font-bold text-4xl text-white">LOGIN CALLBACK</p>
51
- {/* {profile && JSON.stringify(profile, null, 2)} */}
52
  </div>
53
  );
54
  }
 
7
  `${process.env.OAUTH_CLIENT_ID}:${process.env.OAUTH_CLIENT_SECRET}`
8
  ).toString("base64")}`;
9
 
10
+ const request = await fetch("https://huggingface.co/oauth/token", {
11
+ method: "POST",
12
+ headers: {
13
+ "Content-Type": "application/x-www-form-urlencoded",
14
+ Authorization,
15
+ },
16
+ // send as Form data
17
+ body: new URLSearchParams({
18
+ grant_type: "authorization_code",
19
+ code,
20
+ redirect_uri: REDIRECT_URI,
21
+ }),
22
+ });
23
 
24
+ const response = await request
25
+ .clone()
26
+ .json()
27
+ .catch(() => ({}));
28
 
29
  // console.log(response);
30
  // if (!response.access_token) {
31
  // return response;
32
  // }
33
+ // @ts-ignore
34
  // cookies.set("access_token", response.access_token, {});
35
 
36
+ return {
37
+ ...response,
38
+ client_id: process.env.OAUTH_CLIENT_SECRET,
39
+ };
40
  } catch (error) {
41
  return error;
42
  }
 
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>
56
  );
57
  }