You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tutorials/faq.mdx
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,14 @@ Submit an [application](/request-access) to receive your `client_id` and `client
26
26
27
27
Include your OAuth2 access token in the `x-auth-token` header and your client ID in the `x-client-id` header when calling authenticated endpoints.
28
28
29
+
For web apps, the recommended pattern is to store the user session in your backend or secure `httpOnly` cookies and have your backend or serverless proxy send `x-auth-token` and `x-client-id` to Quran Foundation.
30
+
31
+
## Why does the same request work in curl but fail in the browser?
32
+
33
+
`curl` usually sends no browser `Origin` header, while browser JavaScript does. If you call a User API directly from page code on a third-party origin, the request can be rejected by the target service's browser-origin policy even when the token itself is valid.
34
+
35
+
For confidential web integrations, route the resource request through your backend or serverless proxy instead of calling Quran Foundation directly from the page.
36
+
29
37
## What are the best practices for refresh tokens?
30
38
31
39
Store refresh tokens securely and reuse them until they expire. Refresh tokens allow you to obtain new access tokens without asking the user to re-authorize.
Copy file name to clipboardExpand all lines: docs/tutorials/oidc/example-integration.mdx
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -76,6 +76,8 @@ const response = await fetch(
76
76
constbookmarks=awaitresponse.json();
77
77
```
78
78
79
+
This example keeps the user session on the server and uses the server to send `x-auth-token` and `x-client-id` to Quran Foundation. That is the recommended pattern for confidential web clients. If you move the resource call into frontend browser code, you leave that server-side pattern and may run into browser-origin restrictions.
80
+
79
81
## Accessing Resources
80
82
81
83
Once authenticated, explore the [User APIs](/docs/category/user-related-apis):
App->>API: Use token to call Quran.Foundation's API
236
-
API-->>App: Requested resource
235
+
App->>Backend: Request resource
236
+
Backend->>API: Use token to call Quran.Foundation's API
237
+
API-->>Backend: Requested resource
238
+
Backend-->>App: Requested resource
237
239
238
240
Note over App,Backend: Access token expires (1 hour)
239
241
@@ -757,6 +759,8 @@ x-client-id: YOUR_CLIENT_ID
757
759
758
760
Note: the collections examples below require the `collection` scope, and other User API endpoints may require additional scopes such as `user`. A token granted only `openid offline_access` is sufficient for login and refresh, but not for every User API call.
759
761
762
+
For confidential web clients, the recommended pattern is to have your backend or serverless proxy send these headers on outbound requests to Quran Foundation. Your app can keep the user session in a server session or secure `httpOnly` cookies while the backend injects `x-auth-token` and `x-client-id`.
- Token storage: Store `refresh_token` securely; rotate if compromised.
1016
+
- Browser-origin policy: Direct browser calls to User APIs require the calling origin to be allowlisted by the target service. If your origin is not allowlisted, call the API from your backend instead.
1010
1017
- Clock skew: Ensure system time is correct (e.g., via NTP) to avoid `invalid_grant` due to time drift.
1011
1018
1012
1019
> Do not mix tokens across environments. A token from Pre-Production will not work on Production, and vice versa.
@@ -1054,6 +1061,7 @@ Acceptance checklist
1054
1061
|`redirect_uri_mismatch`| Redirect URI not exact match | Align with registered value |
1055
1062
|`invalid_scope`| Scope misspelled or not allowed | Use valid scopes; request incrementally |
|`403 Forbidden` (APIs) | Direct browser call from a restricted origin, or scope/permission is not granted | For web apps, route the request through your backend or proxy; otherwise use a supported browser origin and request the correct scope |
See [Step 4: Call User APIs with Headers](#step-4-call-user-apis-with-headers) for complete examples in cURL, JavaScript, and Python.
1144
+
For web apps, your backend or serverless proxy should usually be the component that sends these headers to Quran Foundation. See [Step 4: Call User APIs with Headers](#step-4-call-user-apis-with-headers) for complete examples in cURL, JavaScript, and Python.
Copy file name to clipboardExpand all lines: docs/tutorials/oidc/user-apis-quickstart.mdx
+11Lines changed: 11 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,14 @@ Quran Foundation User APIs use OAuth2 Authorization Code flow with PKCE and Open
36
36
37
37
This pattern gives you OAuth2 and OpenID Connect without embedding secrets in a mobile app or browser app. It also keeps the integration aligned with how most Request Access clients are provisioned today.
38
38
39
+
For web apps, the recommended shape is:
40
+
41
+
- keep token exchange and refresh on your backend
42
+
- keep the app's user session in secure server storage or `httpOnly` cookies
43
+
- have your backend or serverless proxy send `x-auth-token` and `x-client-id` when calling Quran Foundation User APIs
44
+
45
+
Direct browser calls from third-party origins are not the recommended web pattern and may be rejected by CORS allowlisting or other origin allowlist checks.
46
+
39
47
## Choose Your Platform
40
48
41
49
Use the quickstart guidance on this page for the architecture decision, then jump to the guide that matches your stack.
@@ -87,6 +95,8 @@ const response = await fetch(
87
95
constbookmarks=awaitresponse.json();
88
96
```
89
97
98
+
For web apps, this request is typically made by your backend or serverless proxy, not by page JavaScript. Cookies are for your app's own session; `x-auth-token` and `x-client-id` are the headers your server sends to Quran Foundation.
99
+
90
100
## Quick Reference
91
101
92
102
### Common scopes
@@ -120,6 +130,7 @@ Request only the scopes your app actually needs.
120
130
- Mixing prelive and production OAuth2 environments.
121
131
- Requesting more scopes than your app needs.
122
132
- Treating the `id_token` as an API access token instead of using the `access_token`.
133
+
- Calling User APIs directly from browser JavaScript in a confidential web integration instead of routing the request through your backend or proxy.
0 commit comments