Retrieveing User Profile Information

I’m developing an Angular 8 SPA and have successfully integrated Auth0 authentication.The profile information for each user displays just as the tutorial shows. How do I access the email property?

  "nickname": "user,
  "name": "",
  "picture": "",
  "updated_at": "2020-01-15T17:39:10.467Z",
  "email": "",
  "email_verified": true,
  "sub": "auth0|000000000000000000000000"

In app.module.ts, I tried subscribing with the following:

currentUser: string;
this.auth.userProfile$.subscribe(userProfile => {this.currentUser = userProfile});

However, in the console I just get: null. As far as I can tell, auth.service.ts provides the necessary observable:

private userProfileSubject$ = new BehaviorSubject<any>(null);
userProfile$ = this.userProfileSubject$.asObservable();

Any direction is appreciated.

1 Like

Hi @ibuoprofen,

Welcome and thank you for posting in Auth0 Community!

Do you have the scope: 'openid profile email' under your src/environments/environment.ts file?

It should look something like this:

// environment.ts
export const environment = {
  production: false,
  auth: {
    clientID: 'YOUR-AUTH0-CLIENT-ID',
    domain: 'YOUR-AUTH0-DOMAIN', // e.g.,
    audience: 'YOUR-AUTH0-API-IDENTIFIER', // e.g., http://localhost:3001
    redirect: 'http://localhost:4200/callback',
    scope: 'openid profile email'