http://localhost:4200
.http://localhost:4200
.http://localhost:4200
.provideAuth0
, which is a provide function that contains all the services required
for the SDK to function. To register this with your application:main.ts
file.provideAuth0
function from the @auth0/auth0-angular
package.provideAuth0
to the application by adding it to the providers
inside
bootstrapApplication
.AuthService
into AppComponent
.provideAuth0
function takes the properties domain
and clientId
; the
values of these properties correspond to the Domain and Client ID values that you can find under
Settings in the Single-Page Application (SPA) that you registered with Auth0. On top of that, we configure
authorizationParams.redirect_uri
, which allows Auth0 to redirect the user back to the specific URL
after successfully authenticating.loginWithRedirect()
method from the
AuthService
class to redirect users to the Auth0 Universal Login page where Auth0 can authenticate
them. After a user successfully authenticates, they will be redirected to your application and the callback URL
you set up earlier in this quickstart.Create a login button in your application that calls loginWithRedirect()
when selected.logout()
method on the
AuthService
class that you can use to log a user out of your app. When users log out, they will be
redirected to your Auth0
logout endpoint, which will then immediately redirect them to your application and the logout URL you set up
earlier in this quickstart.Create a logout button in your application that calls logout()
when selected.isAuthenticated$
observable on the AuthService
class that
allows you to check whether a user is authenticated or not. You can render the login and logout buttons
conditionally based on the value of the isAuthenticated$
observable. Alternatively, you can
use a single button to combine both login and logout buttons as well as their conditional rendering.user$
observable exposed by the
AuthService
class. Because the user$
observable contains sensitive information and
artifacts related to the user’s identity, its availability depends on the user’s authentication status.
Fortunately, the user$
observable is configured to only emit values once the
isAuthenticated$
observable is true, so there is no need to manually check the authentication state
before accessing the user profile data.The SDK also exposes an isAuthenticated$
observable on the AuthService
class that
allows you to check whether a user is authenticated or not, which you can use to determine whether to show or hide
UI elements, for example.Review the UserProfileComponent
code in the interactive panel to see examples of how to use these
functions.