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
Always render the `error` field from `useCriiptoVerify`. It surfaces both **configuration errors** (e.g. invalid `domain` or `clientID`, or CORS) raised when the provider mounts, and **runtime errors** raised during a login attempt (e.g. user cancellation, OAuth2 errors from the IdP). Without rendering `error`, misconfiguration and failed logins will appear silent to the user.
68
+
69
+
## CORS
70
+
71
+
The library makes fetch requests to Criipto for two reasons:
72
+
73
+
1. To load application configuration when the provider mounts.
74
+
2. To push the authorization request (PAR) when a user clicks a login button.
75
+
76
+
Make sure that the origin your React app runs on is included in the list of callback URLs for your application. Otherwise, both calls will fail with CORS errors.
77
+
71
78
## Sessions
72
79
73
80
If you want to use `@criipto/verify-react` for session management (rather than one-off authentication) you can configure a `sessionStore`:
@@ -102,7 +109,7 @@ You may wish to increase the "Token lifetime" setting of your Criipto Applicatio
@@ -119,7 +126,11 @@ export default function App() {
119
126
<React.Fragment>
120
127
{error ? (
121
128
<p>
122
-
An error occured: {error.error} ({error.error_description}). Pleasetry again:
129
+
An error occured:{''}
130
+
{error instanceof OAuth2Error
131
+
?`${error.error} (${error.error_description})`
132
+
:String(error)}
133
+
. Pleasetry again.
123
134
</p>
124
135
) :null}
125
136
<AuthMethodSelector />
@@ -153,10 +164,6 @@ useEffect(() => {
153
164
}, [isLoading, isInitializing]);
154
165
```
155
166
156
-
## XHR/fetch caveats
157
-
158
-
The library may require to do fetch requests against Criipto to fetch application configuration. Make sure that the host that the React app runs on is included in the list of callback URLs for your application. Otherwise, you will encounter CORS errors.
159
-
160
167
## Criipto
161
168
162
169
Learn more about Criipto and sign up for your free developer account at [criipto.com](https://www.criipto.com).
0 commit comments