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: README.md
+29Lines changed: 29 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -262,6 +262,35 @@ The `accessTokenTTL` override is particularly useful when the application is als
262
262
263
263
The `props` values are end-to-end encrypted, so they can safely contain sensitive information.
264
264
265
+
## Custom Error Responses
266
+
267
+
By using the `onError` option, you can emit notifications or take other actions when an error response was to be emitted:
268
+
269
+
```ts
270
+
newOAuthProvider({
271
+
// ... other options ...
272
+
onError({ code, description, status, headers }) {
273
+
Sentry.captureMessage(/* ... */)
274
+
}
275
+
})
276
+
```
277
+
278
+
By returning a `Response` you can also override what the OAuthProvider returns to your users:
279
+
280
+
```ts
281
+
newOAuthProvider({
282
+
// ... other options ...
283
+
onError({ code, description, status, headers }) {
284
+
if (code==='unsupported_grant_type') {
285
+
returnnewResponse('...', { status, headers })
286
+
}
287
+
// returning undefined (i.e. void) uses the default Response generation
288
+
}
289
+
})
290
+
```
291
+
292
+
By default, the `onError` callback is set to ``({ status, code, description }) => console.warn(`OAuth error response: ${status} ${code} - ${description}`)``.
0 commit comments