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
+38-27
Original file line number
Diff line number
Diff line change
@@ -21,12 +21,16 @@ A library for integrating [Auth0](https://auth0.com) into an Angular 9+ applicat
21
21
22
22
## Installation
23
23
24
-
Using `npm`:
24
+
The package is still not available on the NPM public registry.
25
+
26
+
In order to install it, visit the [RELEASES](https://github.com/auth0/auth0-angular/releases) section, download the `.tgz` file, and run the following `npm` command:
Make sure the path and filename matches the file you've downloaded.
33
+
30
34
## Getting Started
31
35
32
36
-[Register the authentication module](#register-the-authentication-module)
@@ -52,15 +56,15 @@ import { AuthModule } from '@auth0/auth0-angular';
52
56
declarations: [AppComponent],
53
57
imports: [
54
58
BrowserModule,
55
-
59
+
56
60
// Import the module into the application, with configuration
57
61
AuthModule.forRoot({
58
62
domain:'YOUR_AUTH0_DOMAIN',
59
63
clientId:'YOUR_AUTH0_CLIENT_ID',
60
-
redirectUri:window.location.origin
61
-
})
64
+
redirectUri:window.location.origin,
65
+
}),
62
66
],
63
-
67
+
64
68
bootstrap: [AppComponent],
65
69
})
66
70
exportclassAppModule {}
@@ -97,7 +101,12 @@ export class AppComponent {
97
101
On your template, provide a button that will allow the user to log in to the application. Use the `isAuthenticated$` observable to check that the user is not already authenticated:
Then on your component's template, add a button that will log the user out of the application. Use the `isAuthenticated$` observable to check that the user has already been authenticated:
// Protect a route by registering the auth guard in the `canActivate` hook
152
-
canActivate: [AuthGuard]
163
+
canActivate: [AuthGuard],
153
164
},
154
165
{
155
166
path:'',
156
167
component: HomeComponent,
157
-
pathMatch:'full'
168
+
pathMatch:'full',
158
169
},
159
170
];
160
171
161
172
@NgModule({
162
173
imports: [RouterModule.forRoot(routes)],
163
-
exports: [RouterModule]
174
+
exports: [RouterModule],
164
175
})
165
176
exportclassAppRoutingModule {}
166
177
```
@@ -206,41 +217,41 @@ AuthModule.forRoot({
206
217
domain:'YOUR_AUTH0_DOMAIN',
207
218
clientId:'YOUR_AUTH0_CLIENT_ID',
208
219
redirectUri:window.location.origin,
209
-
220
+
210
221
// The HttpInterceptor configuration
211
222
httpInterceptor: {
212
223
allowedList: [
213
224
// Use a string to match the URL exactly
214
225
'/api',
215
-
226
+
216
227
// Use a regex to match anything starting with /api
217
228
/^\/api/,
218
-
229
+
219
230
// The same as above, but with an object
220
231
{
221
-
uri:/^\/api/// can be a string or regex
232
+
uri:/^\/api/,// can be a string or regex
222
233
},
223
-
234
+
224
235
// The same as above but also specifying the audience and scope the token must have
225
236
{
226
237
uri:/^\/api/,
227
238
tokenOptions: {
228
239
audience:'http://my-api/',
229
-
scope:'read:accounts'
230
-
}
240
+
scope:'read:accounts',
241
+
},
231
242
},
232
-
243
+
233
244
// Using an absolute URI
234
245
{
235
246
uri:'https://your-domain.auth0.com/api/v2/users',
236
247
tokenOptions: {
237
248
audience:'https://your-domain.com/api/v2/',
238
-
scope:'read:users'
239
-
}
240
-
}
241
-
]
242
-
}
243
-
})
249
+
scope:'read:users',
250
+
},
251
+
},
252
+
],
253
+
},
254
+
});
244
255
```
245
256
246
257
> Under the hood, `tokenOptions` is passed as-is to [the `getTokenSilently` method](https://auth0.github.io/auth0-spa-js/classes/auth0client.html#gettokensilently) on the underlying SDK, so all the same options apply here.
@@ -250,7 +261,7 @@ Finally, make your API call using the `HttpClient`. Access tokens are then attac
0 commit comments