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
-[Configure AuthHttpInterceptor to attach access tokens](#configure-authhttpinterceptor-to-attach-access-tokens)
13
+
-[Handling errors](#handling-errors)
14
+
-[Organizations](#organizations)
15
+
-[Log in to an organization](#log-in-to-an-organization)
16
+
-[Accept user invitations](#accept-user-invitations)
17
+
-[Standalone components and a more functional approach](#standalone-components-and-a-more-functional-approach)
12
18
13
19
## Add login to your application
14
20
@@ -157,7 +163,7 @@ import { AuthModule } from '@auth0/auth0-angular';
157
163
clientId: 'YOUR_AUTH0_CLIENT_ID',
158
164
authorizationParams: {
159
165
audience: 'YOUR_AUTH0_API_IDENTIFIER',
160
-
}
166
+
},
161
167
}),
162
168
],
163
169
// ...
@@ -278,7 +284,7 @@ AuthModule.forRoot({
278
284
authorizationParams: {
279
285
audience: 'http://my-api/',
280
286
scope: 'write:orders',
281
-
}
287
+
},
282
288
},
283
289
},
284
290
],
@@ -381,6 +387,7 @@ export class AppComponent {
381
387
```
382
388
383
389
## Standalone components and a more functional approach
390
+
384
391
As of Angular 15, the Angular team is putting standalone components, as well as a more functional approach, in favor of the traditional use of NgModules and class-based approach.
385
392
386
393
There are a couple of difference with how you would traditionally implement our SDK:
@@ -398,18 +405,31 @@ const routes: Routes = [
398
405
path: 'profile',
399
406
component: ProfileComponent,
400
407
canActivate: [authGuardFn],
401
-
}
408
+
},
402
409
];
403
410
404
411
bootstrapApplication(AppComponent, {
405
-
providers: [
406
-
provideRouter(routes),
407
-
provideAuth0(/* Auth Config Goes Here */),
408
-
provideHttpClient(
409
-
withInterceptors([authHttpInterceptorFn])
410
-
)
411
-
]
412
+
providers: [provideRouter(routes), provideAuth0(/* Auth Config Goes Here */), provideHttpClient(withInterceptors([authHttpInterceptorFn]))],
412
413
});
413
414
```
414
415
415
416
Note that `provideAuth0` should **never** be provided to components, but only at the root level of your application.
417
+
418
+
`AuthConfig` can be omitted or it can be provided either as a basic config object, or a function that returns a config object:
419
+
420
+
```ts
421
+
provideAuth0({
422
+
clientId: 'clientId',
423
+
domain: 'domain',
424
+
}),
425
+
// or
426
+
provideAuth0(() => {
427
+
const someProvider =inject(SomeProvider);
428
+
// you can inject as many providers as you want
429
+
return {
430
+
clientId:'clientId',
431
+
domain:'domain',
432
+
// use someProvider (or other porviders) to build your config object
0 commit comments