Skip to content

Commit d4932af

Browse files
Merge pull request #1778 from timdeschryver/docs/standalone
docs: adds docs for standalone methods
2 parents 4b09bb6 + 50b468a commit d4932af

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

docs/site/angular-auth-oidc-client/docs/documentation/configuration.md

+23
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,29 @@ import { AuthModule, DefaultLocalStorageService, AbstractSecurityStorage } from
196196
export class AuthConfigModule {}
197197
```
198198

199+
## Configure with standalone config
200+
201+
To configure the auth module by using the standalone API, you can use the `provideAuth` method
202+
203+
```ts
204+
import { ApplicationConfig } from '@angular/core';
205+
import { bootstrapApplication } from '@angular/platform-browser';
206+
import { provideAuth } from 'angular-auth-oidc-client';
207+
import { AppComponent } from './app/app.component';
208+
209+
export const appConfig: ApplicationConfig = {
210+
providers: [
211+
provideAuth({
212+
config: {
213+
/* Your config here */
214+
},
215+
}),
216+
],
217+
};
218+
219+
bootstrapApplication(AppComponent, appConfig);
220+
```
221+
199222
## Config Values
200223

201224
### `configId`

docs/site/angular-auth-oidc-client/docs/documentation/interceptors.md

+25
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,28 @@ If you configured a route to be protected, every child route underneath is prote
4646
In case you are running multiple configurations all the configured routes over all configurations are collected and compared against the currently requested route. If a match is made, the token for the configuration you added the secure route to is being taken and applied in the Authorization header.
4747

4848
Keep in mind that you always can implement your own interceptor as [described in the Angular documentation](https://angular.io/guide/http#intercepting-requests-and-responses).
49+
50+
## Standalone API
51+
52+
To use the standalone API use the `authInterceptor` method
53+
54+
```ts
55+
import { ApplicationConfig } from '@angular/core';
56+
import { bootstrapApplication } from '@angular/platform-browser';
57+
import { provideHttpClient, withInterceptors } from '@angular/common/http';
58+
import { provideAuth, authInterceptor } from 'angular-auth-oidc-client';
59+
import { AppComponent } from './app/app.component';
60+
61+
export const appConfig: ApplicationConfig = {
62+
providers: [
63+
provideHttpClient(withInterceptors([authInterceptor()])),
64+
provideAuth({
65+
config: {
66+
/* Your config here */
67+
},
68+
}),
69+
],
70+
};
71+
72+
bootstrapApplication(AppComponent, appConfig);
73+
```

projects/sample-code-flow-standalone/src/app/app.config.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { provideHttpClient } from '@angular/common/http';
1+
import { provideHttpClient, withInterceptors } from '@angular/common/http';
22
import { ApplicationConfig } from '@angular/core';
33
import {
44
provideRouter,
55
withEnabledBlockingInitialNavigation,
66
} from '@angular/router';
77
import {
88
LogLevel,
9+
authInterceptor,
910
autoLoginPartialRoutesGuard,
1011
provideAuth,
1112
} from 'angular-auth-oidc-client';
@@ -16,7 +17,7 @@ import { UnauthorizedComponent } from './unauthorized/unauthorized.component';
1617

1718
export const appConfig: ApplicationConfig = {
1819
providers: [
19-
provideHttpClient(),
20+
provideHttpClient(withInterceptors([authInterceptor()])),
2021
provideAuth({
2122
config: {
2223
triggerAuthorizationResultEvent: true,

0 commit comments

Comments
 (0)