jbilcke-hf HF staff commited on
Commit
0fcac01
1 Parent(s): aaf5911
Files changed (3) hide show
  1. .env +2 -0
  2. README.md +0 -1
  3. src/lib/useHuggingFaceLogin.ts +44 -1
.env CHANGED
@@ -3,6 +3,8 @@ NEXT_PUBLIC_SHOW_BETA_FEATURES="false"
3
 
4
  NEXT_PUBLIC_DEVELOPER_MODE="false"
5
 
 
 
6
  ADMIN_HUGGING_FACE_API_TOKEN=""
7
  ADMIN_HUGGING_FACE_USERNAME=""
8
 
 
3
 
4
  NEXT_PUBLIC_DEVELOPER_MODE="false"
5
 
6
+ NEXT_PUBLIC_AI_TUBE_OAUTH_CLIENT_ID="35c3efbc-d51f-4763-b5ea-3e149c6158e5"
7
+
8
  ADMIN_HUGGING_FACE_API_TOKEN=""
9
  ADMIN_HUGGING_FACE_USERNAME=""
10
 
README.md CHANGED
@@ -7,7 +7,6 @@ sdk: docker
7
  pinned: true
8
  app_port: 3000
9
  disable_embedding: false
10
- hf_oauth: true
11
  ---
12
 
13
  # 🍿 AI Tube
 
7
  pinned: true
8
  app_port: 3000
9
  disable_embedding: false
 
10
  ---
11
 
12
  # 🍿 AI Tube
src/lib/useHuggingFaceLogin.ts CHANGED
@@ -19,7 +19,50 @@ export function useHuggingFaceLogin(onLogin?: (data: any) => void) {
19
  }, [])
20
 
21
  const login = async () => {
22
- window.location.href = await oauthLoginUrl()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  }
24
 
25
  console.log(JSON.stringify(oauthResult, null, 2))
 
19
  }, [])
20
 
21
  const login = async () => {
22
+ const oauthUrl = await oauthLoginUrl({
23
+ /**
24
+ * OAuth client ID.
25
+ *
26
+ * For static Spaces, you can omit this and it will be loaded from the Space config, as long as `hf_oauth: true` is present in the README.md's metadata.
27
+ * For other Spaces, it is available to the backend in the OAUTH_CLIENT_ID environment variable, as long as `hf_oauth: true` is present in the README.md's metadata.
28
+ *
29
+ * You can also create a Developer Application at https://huggingface.co/settings/connected-applications and use its client ID.
30
+ */
31
+ clientId: process.env.NEXT_PUBLIC_AI_TUBE_OAUTH_CLIENT_ID,
32
+
33
+ // hubUrl?: string;
34
+
35
+ /**
36
+ * OAuth scope, a list of space separate scopes.
37
+ *
38
+ * For static Spaces, you can omit this and it will be loaded from the Space config, as long as `hf_oauth: true` is present in the README.md's metadata.
39
+ * For other Spaces, it is available to the backend in the OAUTH_SCOPES environment variable, as long as `hf_oauth: true` is present in the README.md's metadata.
40
+ *
41
+ * Defaults to "openid profile".
42
+ *
43
+ * You can also create a Developer Application at https://huggingface.co/settings/connected-applications and use its scopes.
44
+ *
45
+ * See https://huggingface.co/docs/hub/oauth for a list of available scopes.
46
+ */
47
+ scopes: "openid profile",
48
+
49
+ /**
50
+ * Redirect URI, defaults to the current URL.
51
+ *
52
+ * For Spaces, any URL within the Space is allowed.
53
+ *
54
+ * For Developer Applications, you can add any URL you want to the list of allowed redirect URIs at https://huggingface.co/settings/connected-applications.
55
+ */
56
+ redirectUrl: "https://jbilcke-hf-ai-tube.hf.space",
57
+
58
+ /**
59
+ * State to pass to the OAuth provider, which will be returned in the call to `oauthLogin` after the redirect.
60
+ */
61
+ // state: ""
62
+ })
63
+
64
+ console.log("oauthUrl:", oauthUrl)
65
+ window.location.href = oauthUrl
66
  }
67
 
68
  console.log(JSON.stringify(oauthResult, null, 2))