Oysiyl commited on
Commit
973546b
·
1 Parent(s): 3574fa8

Enable HF OAuth in Space metadata

Browse files
Files changed (1) hide show
  1. README.md +70 -51
README.md CHANGED
@@ -6,59 +6,78 @@ colorTo: pink
6
  sdk: gradio
7
  sdk_version: 5.49.1
8
  app_file: app.py
 
9
  pinned: false
10
  license: apache-2.0
11
  tags:
12
  - mcp-server-track
13
  ---
14
-
15
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
16
-
17
-
18
- ## Demo
19
- [Watch the demo video](showcase.mp4)
20
-
21
- ## Optional analytics
22
-
23
- The Space includes an optional analytics consent toggle for both UI and MCP usage.
24
-
25
- - Generated images are not used for analytics.
26
- - Full prompts, QR payload text, and settings are only stored when analytics opt-in is enabled.
27
- - Minimal operational events can still be logged for reliability and product metrics.
28
-
29
- ## URL normalization
30
-
31
- When `Input Type` is set to `URL`, the app normalizes links on CPU before any GPU work starts.
32
-
33
- - Common tracking params such as `utm_*`, `fbclid`, and `gclid` are removed automatically.
34
- - Scheme and host casing are normalized to reduce unnecessary QR payload length.
35
- - Plain text payloads are left untouched.
36
-
37
- ## Temporary short links
38
-
39
- When enabled in the UI, URL mode can replace the QR payload with a `qrcut.co` short link.
40
-
41
- - The shortener is opt-in and defaults to off.
42
- - Short links expire after 7 days of inactivity.
43
- - If the shortener is unavailable, generation falls back to the normalized original URL.
44
-
45
- ### Required Space secrets
46
-
47
- - `SUPABASE_URL`
48
- - `SUPABASE_SERVICE_ROLE_KEY`
49
- - `POSTHOG_API_KEY` (or reuse `POSTHOG_SECRET_KEY`)
50
- - `POSTHOG_HOST` (optional, defaults to `https://us.i.posthog.com`)
51
- - `ANALYTICS_ENABLED` (optional, defaults to `true`)
52
- - `ANALYTICS_DEFAULT_OPT_IN` (optional, defaults to `false`)
53
- - `ANALYTICS_PRODUCT` (optional, defaults to `ai_qr_generator`; set Modal/iOS deployments to `arti_qrcode_app` when sharing the same analytics tables)
54
- - `URL_SHORTENER_API_URL` (optional, for example `https://qrcut.co/shorten`)
55
- - `URL_SHORTENER_API_KEY` (optional, private API key for the HF Space)
56
- - `URL_SHORTENER_SOURCE_APP` (optional, defaults to `ai_qr_generator`)
57
- - `URL_SHORTENER_TIMEOUT_SECONDS` (optional, defaults to `10`)
58
-
59
- ### Supabase schema
60
-
61
- Apply `analytics_supabase_schema.sql` to your Supabase project before enabling writes from the Space.
62
-
63
- The analytics schema is intended for backend-only writes using `SUPABASE_SERVICE_ROLE_KEY`.
64
- Do not grant `anon` or `authenticated` direct access to the analytics tables or derived views.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  sdk: gradio
7
  sdk_version: 5.49.1
8
  app_file: app.py
9
+ hf_oauth: true
10
  pinned: false
11
  license: apache-2.0
12
  tags:
13
  - mcp-server-track
14
  ---
15
+
16
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
17
+
18
+
19
+ ## Demo
20
+ [Watch the demo video](showcase.mp4)
21
+
22
+ ## Optional analytics
23
+
24
+ The Space includes an optional analytics consent toggle for both UI and MCP usage.
25
+
26
+ - Generated images are not used for analytics.
27
+ - Full prompts, QR payload text, and settings are only stored when analytics opt-in is enabled.
28
+ - Minimal operational events can still be logged for reliability and product metrics.
29
+
30
+ ## URL normalization
31
+
32
+ When `Input Type` is set to `URL`, the app normalizes links on CPU before any GPU work starts.
33
+
34
+ - Common tracking params such as `utm_*`, `fbclid`, and `gclid` are removed automatically.
35
+ - Scheme and host casing are normalized to reduce unnecessary QR payload length.
36
+ - Plain text payloads are left untouched.
37
+
38
+ ## Temporary short links
39
+
40
+ When enabled in the UI, URL mode can replace the QR payload with a `qrcut.co` short link.
41
+
42
+ - The shortener is opt-in and defaults to off.
43
+ - Short links expire after 7 days of inactivity.
44
+ - If the shortener is unavailable, generation falls back to the normalized original URL.
45
+
46
+ ### Required Space secrets
47
+
48
+ - `SUPABASE_URL`
49
+ - `SUPABASE_SERVICE_ROLE_KEY`
50
+ - `POSTHOG_API_KEY` (or reuse `POSTHOG_SECRET_KEY`)
51
+ - `POSTHOG_HOST` (optional, defaults to `https://us.i.posthog.com`)
52
+ - `ANALYTICS_ENABLED` (optional, defaults to `true`)
53
+ - `ANALYTICS_DEFAULT_OPT_IN` (optional, defaults to `false`)
54
+ - `ANALYTICS_PRODUCT` (optional, defaults to `ai_qr_generator`; use as the deployment default)
55
+ - `URL_SHORTENER_API_URL` (optional, for example `https://qrcut.co/shorten`)
56
+ - `URL_SHORTENER_API_KEY` (optional, private API key for the HF Space)
57
+ - `URL_SHORTENER_SOURCE_APP` (optional, defaults to `ai_qr_generator`; used as the fallback caller app when requests do not provide an override header)
58
+ - `URL_SHORTENER_TIMEOUT_SECONDS` (optional, defaults to `10`)
59
+
60
+ ### Hugging Face OAuth
61
+
62
+ `OAUTH_CLIENT_ID` and `OAUTH_CLIENT_SECRET` are not manual Space secrets here.
63
+ They are injected automatically by Hugging Face when `hf_oauth: true` is present in the Space metadata.
64
+
65
+ ### Optional request headers for shared backends
66
+
67
+ When multiple surfaces share the same generator backend, the caller can override attribution per request:
68
+
69
+ - `X-Source-App`: per-request caller identity used for qrcut `source_app` and stored as `caller_app` in analytics
70
+ - `X-Analytics-Product`: optional per-request analytics product override; if omitted, backend uses `ANALYTICS_PRODUCT`
71
+
72
+ Recommended pattern:
73
+
74
+ - HF Space traffic: send no override headers and let the backend default to `ai_qr_generator`
75
+ - Arti iOS traffic: send `X-Source-App: arti_qrcode_app`
76
+ - if Arti should also write into a separate analytics product lane, additionally send `X-Analytics-Product: arti_qrcode_app`
77
+
78
+ ### Supabase schema
79
+
80
+ Apply `analytics_supabase_schema.sql` to your Supabase project before enabling writes from the Space.
81
+
82
+ The analytics schema is intended for backend-only writes using `SUPABASE_SERVICE_ROLE_KEY`.
83
+ Do not grant `anon` or `authenticated` direct access to the analytics tables or derived views.