Skip to content

Commit 6adefa2

Browse files
committed
add EA install notes to the readme
1 parent 6f7b546 commit 6adefa2

File tree

1 file changed

+38
-27
lines changed

1 file changed

+38
-27
lines changed

README.md

+38-27
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@ A library for integrating [Auth0](https://auth0.com) into an Angular 9+ applicat
2121

2222
## Installation
2323

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:
2527

2628
```
27-
npm install @auth0/auth0-angular
29+
npm install /path/to/auth0-auth0-angular-x.y.z.tgz
2830
```
2931

32+
Make sure the path and filename matches the file you've downloaded.
33+
3034
## Getting Started
3135

3236
- [Register the authentication module](#register-the-authentication-module)
@@ -52,15 +56,15 @@ import { AuthModule } from '@auth0/auth0-angular';
5256
declarations: [AppComponent],
5357
imports: [
5458
BrowserModule,
55-
59+
5660
// Import the module into the application, with configuration
5761
AuthModule.forRoot({
5862
domain: 'YOUR_AUTH0_DOMAIN',
5963
clientId: 'YOUR_AUTH0_CLIENT_ID',
60-
redirectUri: window.location.origin
61-
})
64+
redirectUri: window.location.origin,
65+
}),
6266
],
63-
67+
6468
bootstrap: [AppComponent],
6569
})
6670
export class AppModule {}
@@ -97,7 +101,12 @@ export class AppComponent {
97101
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:
98102

99103
```html
100-
<button *ngIf="(auth.isAuthenticated$ | async) === false" (click)="loginWithRedirect()">Log in</button>
104+
<button
105+
*ngIf="(auth.isAuthenticated$ | async) === false"
106+
(click)="loginWithRedirect()"
107+
>
108+
Log in
109+
</button>
101110
```
102111

103112
### Add logout to your application
@@ -114,7 +123,9 @@ logout() {
114123
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:
115124

116125
```html
117-
<button *ngIf="auth.isAuthenticated$ | async" (click)="logout()">Log out</button>
126+
<button *ngIf="auth.isAuthenticated$ | async" (click)="logout()">
127+
Log out
128+
</button>
118129
```
119130

120131
### Display the user profile
@@ -147,20 +158,20 @@ const routes: Routes = [
147158
{
148159
path: 'protected',
149160
component: ProtectedComponent,
150-
161+
151162
// Protect a route by registering the auth guard in the `canActivate` hook
152-
canActivate: [AuthGuard]
163+
canActivate: [AuthGuard],
153164
},
154165
{
155166
path: '',
156167
component: HomeComponent,
157-
pathMatch: 'full'
168+
pathMatch: 'full',
158169
},
159170
];
160171

161172
@NgModule({
162173
imports: [RouterModule.forRoot(routes)],
163-
exports: [RouterModule]
174+
exports: [RouterModule],
164175
})
165176
export class AppRoutingModule {}
166177
```
@@ -206,41 +217,41 @@ AuthModule.forRoot({
206217
domain: 'YOUR_AUTH0_DOMAIN',
207218
clientId: 'YOUR_AUTH0_CLIENT_ID',
208219
redirectUri: window.location.origin,
209-
220+
210221
// The HttpInterceptor configuration
211222
httpInterceptor: {
212223
allowedList: [
213224
// Use a string to match the URL exactly
214225
'/api',
215-
226+
216227
// Use a regex to match anything starting with /api
217228
/^\/api/,
218-
229+
219230
// The same as above, but with an object
220231
{
221-
uri: /^\/api/ // can be a string or regex
232+
uri: /^\/api/, // can be a string or regex
222233
},
223-
234+
224235
// The same as above but also specifying the audience and scope the token must have
225236
{
226237
uri: /^\/api/,
227238
tokenOptions: {
228239
audience: 'http://my-api/',
229-
scope: 'read:accounts'
230-
}
240+
scope: 'read:accounts',
241+
},
231242
},
232-
243+
233244
// Using an absolute URI
234245
{
235246
uri: 'https://your-domain.auth0.com/api/v2/users',
236247
tokenOptions: {
237248
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+
});
244255
```
245256

246257
> 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
250261
```js
251262
export class MyComponent {
252263
constructor(private http: HttpClient) {}
253-
264+
254265
callApi() {
255266
this.http.get('/api').subscribe(result => console.log(result));
256267
}

0 commit comments

Comments
 (0)