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
@@ -87,23 +87,131 @@ To redirect users to specific sections after login, use this URL format: `https:
87
87
</Tab>
88
88
<Tabtitle="OAuth 2.0">
89
89
### Prerequisites
90
-
- You have an existing OAuth server that supports the PKCE flow.
91
-
- You can create a new API endpoint that can be accessed by the returned OAuth access token.
90
+
* An OAuth server that supports the PKCE Flow.
91
+
* Ability to create an API endpoint accessible by OAuth access tokens
92
+
92
93
### Implementation
94
+
<Steps>
95
+
<Steptitle="Create user info API endpoint.">
96
+
Create an API endpoint that:
97
+
* Accepts OAuth access tokens for authentication.
98
+
* Returns user data in the `User` format. See [Sending Data](/authentication-personalization/sending-data) for more information.
99
+
* Defines the scopes for access.
100
+
</Step>
101
+
<Steptitle="Configure your OAuth personalization settings.">
102
+
1. In your dashboard, go to [Authentication](https://dashboard.mintlify.com/settings/deployment/authentication).
103
+
2. Select **Personalization**.
104
+
3. Select **OAuth** and configure these fields:
105
+
***Authorization URL**: Your OAuth authorization endpoint.
106
+
***Client ID**: Your OAuth 2.0 client identifier.
107
+
***Scopes**: Permissions to request. Must match the scopes of the endpoint that you configured in the first step.
108
+
***Token URL**: Your OAuth token exchange endpoint.
109
+
***Info API URL**: Endpoint to retrieve user data for personalization. Created in the first step.
110
+
4. Select **Save changes**
111
+
</Step>
112
+
<Steptitle="Configure your OAuth server.">
113
+
1. Copy the **Redirect URL** from your [authentication settings](https://dashboard.mintlify.com/settings/deployment/authentication).
114
+
2. Add this URL as an authorized redirect URL in your OAuth server configuration.
115
+
</Step>
116
+
</Steps>
117
+
118
+
### Example
119
+
120
+
Your documentation is hosted at `foo.com/docs` and you have an existing OAuth server that supports the PKCE flow. You want to personalize your docs based on user data.
121
+
122
+
**Create a user info endpoint** at `api.foo.com/docs/user-info`, which requires an OAuth access token with the `docs-user-info` scope and responds with the user's custom data:
123
+
124
+
```json
125
+
{
126
+
"content": {
127
+
"firstName": "Jane",
128
+
"lastName": "Doe"
129
+
},
130
+
"groups": ["engineering", "admin"]
131
+
}
132
+
```
133
+
134
+
**Configure your OAuth server details** in your dashboard:
-**Info API URL**: `https://api.foo.com/docs/user-info`
140
+
141
+
**Configure your OAuth server** to allow redirects to your callback URL.
93
142
</Tab>
94
143
<Tabtitle="Shared session">
95
144
### Prerequisites
96
145
97
-
- You have a dashboard or other user portal hosted at your domain.
98
-
- Your users' session credentials are stored as cookies.
99
-
- You can create a new API endpoint at the same origin or a subdomain of your dashboard.
100
-
- If your dashboard is at `foo.com`, the **API URL** must start with `foo.com` or `*.foo.com`
101
-
- If your dashboard is at `dash.foo.com`, the **API URL** must start with `dash.foo.com` or `*.dash.foo.com`
102
-
- Your docs are hosted at the same domain as your dashboard.
103
-
- If your dashboard is at `foo.com`, your **docs** must be hosted at `foo.com` or `*.foo.com`
104
-
- If your dashboard is at `*.foo.com`, your **docs** must be hosted at `foo.com` or `*.foo.com`
146
+
* A dashboard or user portal with cookie-based session authentication.
147
+
* Ability to create an API endpoint at the same origin or subdomain as your dashboard.
148
+
* If your dashboard is at `foo.com`, the **API URL** must start with `foo.com` or `*.foo.com`.
149
+
* If your dashboard is at `dash.foo.com`, the **API URL** must start with `dash.foo.com` or `*.dash.foo.com`.
150
+
* Your docs are hosted at the same domain or subdomain as your dashboard.
151
+
* If your dashboard is at `foo.com`, your **docs** must be hosted at `foo.com` or `*.foo.com`.
152
+
* If your dashboard is at `*.foo.com`, your **docs** must be hosted at `foo.com` or `*.foo.com`.
105
153
106
154
### Implementation
155
+
156
+
<Steps>
157
+
<Steptitle="Create user info API endpoint.">
158
+
Create an API endpoint that:
159
+
* Uses your existing session authentication to identify users
160
+
* Returns user data in the `User` format (see [Sending Data](/authentication-personalization/sending-data))
161
+
* If the API domain and the docs domain **do not exactly match**:
162
+
- Add the docs domain to your API's `Access-Control-Allow-Origin` header (must not be `*`).
163
+
- Set your API's `Access-Control-Allow-Credentials` header to `true`.
164
+
165
+
<Warning>
166
+
Only enable CORS headers on this specific endpoint, not your entire dashboard API.
167
+
</Warning>
168
+
</Step>
169
+
<Steptitle="Configure your personalization settings">
170
+
Go to your [dashboard settings](https://dashboard.mintlify.com/products/authentication) and add the API URL and your Login URL to your Personalization settings.
171
+
1. In your dashboard, go to [Authentication](https://dashboard.mintlify.com/settings/deployment/authentication).
172
+
2. Select **Personalization**.
173
+
3. Select **Shared Session**.
174
+
4. Enter your **Info API URL**, which is the endpoint from the first step.
175
+
5. Enter your **Login URL**, where users log in to your dashboard.
176
+
6. Select **Save changes**
177
+
</Step>
178
+
</Steps>
179
+
180
+
### Examples
181
+
182
+
#### Dashboard at subdomain, docs at subdomain
183
+
184
+
You have a dashboard at `dash.foo.com`, which uses cookie-based session authentication. Your dashboard API routes are hosted at `dash.foo.com/api`. You want to set up personalization for your docs hosted at `docs.foo.com`.
185
+
186
+
**Setup process**:
187
+
1.**Create endpoint**`dash.foo.com/api/docs/user-info` that identifies users via session authentication and responds with their user data.
3.**Configure API URL** in authentication settings: `https://dash.foo.com/api/docs/user-info`.
192
+
193
+
### Dashboard at subdomain, docs at root
194
+
195
+
You have a dashboard at `dash.foo.com`, which uses cookie-based session authentication. Your dashboard API routes are hosted at `dash.foo.com/api`. You want to set up personalization for your docs hosted at `foo.com/docs`.
196
+
197
+
**Setup process**:
198
+
1.**Create endpoint**`dash.foo.com/api/docs/user-info` that identifies users via session authentication and responds with their user data.
199
+
2.**Add CORS headers** for this route only:
200
+
-`Access-Control-Allow-Origin`: `https://foo.com`
201
+
-`Access-Control-Allow-Credentials`: `true`
202
+
3.**Configure API URL** in authentication settings: `https://dash.foo.com/api/docs/user-info`.
203
+
204
+
### Dashboard at root, docs at root
205
+
206
+
You have a dashboard at `foo.com/dashboard`, which uses cookie-based session authentication. Your dashboard API routes are hosted at `foo.com/api`. You want to set up personalization for your docs hosted at `foo.com/docs`.
207
+
208
+
**Setup process**:
209
+
1.**Create endpoint**`foo.com/api/docs/user-info` that identifies users via session authentication and responds with their user data.
210
+
2.**Configure API URL** in authentication settings: `https://foo.com/api/docs/user-info`
211
+
212
+
<Note>
213
+
No CORS configuration is needed since the dashboard and docs share the same domain.
0 commit comments