@asgardeo/auth-react 1.1.6 → 1.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -219,6 +219,8 @@ The provider takes a prop called `config` that accepts a config object of type [
219
219
 
220
220
  In addition, the `fallback` prop is used to specify a fallback component that will be rendered when the user is not authenticated.
221
221
 
222
+ As an optional parameter, `spaClient` parameter can be used to initialize the external Auth SPA Client.
223
+
222
224
  The `AuthProvider` also automatically requests for the access token should the URL contain the `code` query parameter.
223
225
 
224
226
  If the response mode is set to `form_post`, then you will have your own ways of retrieving the authorization code and session state from your backend. In that case, you can use the `getAuthParams()` prop method to pass an async callback function that would return the `authorizationCode` and `sessionState` in a Promise. This way, the `AuthProvider` will use the authorization code returned by this method to automatically request for an access token.
@@ -234,6 +236,20 @@ export const MyApp = (): ReactElement => {
234
236
  )
235
237
  }
236
238
  ```
239
+
240
+ #### Example with External Auth SPA Client
241
+
242
+ ```TypeScript
243
+ import { ChoreoSPAClient } from "@asgardeo/choreo-auth-spa";
244
+
245
+ export const MyApp = (): ReactElement => {
246
+ return (
247
+ <AuthProvider config={ config } spaClient={ ChoreoSPAClient.getInstance() }>
248
+ <Dashboard />
249
+ </AuthProvider>
250
+ )
251
+ }
252
+ ```
237
253
  ---
238
254
  ### SecureRoute
239
255
  The SDK also provides a component called `SecureRoute` that wraps the `Route` component provided by `react-router`dom`. This allows you to secure your routes using the SDK. Only authenticated users will be taken to the route. The component let's you pass a callback function that would be fired if the user is not authenticated.