# Whitelist and catch error using google

**URL:** <https://community.auth0.com/t/whitelist-and-catch-error-using-google/56030>\
**Category:** Get Help\
**Tags:** auth0-angular\
**Created:** [January 12, 2021, 12:45am UTC](https://community.auth0.com/t/whitelist-and-catch-error-using-google/56030 "2021-01-12T00:45:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mayhew3](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mayhew3/32/25437_2.png) [@mayhew3](https://community.auth0.com/u/mayhew3)\
**Post date:** [January 12, 2021, 12:45am UTC](https://community.auth0.com/t/whitelist-and-catch-error-using-google/56030/1 "2021-01-12T00:45:10Z")

</div>

I’m trying to use the auth0-angular library with Angular 10 to allow a specific set of google users to log in to my site.

I found a guide on creating a Whitelist rule, which works okay, but I have a couple questions:

- Is there a way I can feed the list of valid emails into this rule from my app using config or anything? Right now, I just have a hard-coded list of strings in the rules, which adds an unwanted maintenance cost.

- The example throws an UnauthorizedError() in the rule, which doesn’t result in displaying any error page in my app. It just redirects back to the callback with isLoggedIn as false. I tried using the Observable returned by loginWithRedirect() to catch the error, but this error is never thrown.

Thanks,  
Mayhew

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [January 13, 2021, 3:15pm UTC](https://community.auth0.com/t/whitelist-and-catch-error-using-google/56030/3 "2021-01-13T15:15:53Z")

</div>

Hi @mayhew3,

> [@mayhew3](#):
>
> Is there a way I can feed the list of valid emails into this rule from my app using config or anything? Right now, I just have a hard-coded list of strings in the rules, which adds an unwanted maintenance cost.

Do the email addresses share a domain? If so you can use a [domain-specific rule](https://auth0.com/rules/simple-domain-whitelist).

If not, you could store the email addresses in a `.txt` file in Dropbox and reference that in the rule. Here is an example: [Dropbox WhiteList](https://auth0.com/rules/dropbox-whitelist)

You could use this approach with other cloud storage options or [your own protected API](https://community.auth0.com/t/how-do-i-call-my-api-from-a-rule/41309) as well.

> [@mayhew3](#):
>
> The example throws an UnauthorizedError() in the rule, which doesn’t result in displaying any error page in my app. It just redirects back to the callback with isLoggedIn as false. I tried using the Observable returned by loginWithRedirect() to catch the error, but this error is never thrown.

You can capature login errors by subscribing to the `error$` observable

`authService.error$.subscribe((error) => console.log(error));`

If you’re using the [Angular Quick Start](https://auth0.com/docs/quickstart/spa/angular/01-login), you can edit the `ngOnInit` function in the `src/app/components/nav-bar/nav-bar.component.ts` file to log the error:

```auto
  ngOnInit() {
    this.auth.error$.subscribe((error) => console.log(error));
  }

```

Hope that helps!

Stephanie

---

<div class="post-metadata">

**Author:** ![mayhew3](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mayhew3/32/25437_2.png) [@mayhew3](https://community.auth0.com/u/mayhew3)\
**Post date:** [January 15, 2021, 6:45pm UTC](https://community.auth0.com/t/whitelist-and-catch-error-using-google/56030/4 "2021-01-15T18:45:12Z")

</div>

Thanks for your response!

The error$ observable works just like I needed, thanks!

I’m interested in API solution, but would still want to be able to send input from my app about my environment or configuration. Is that possible?

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [January 15, 2021, 6:58pm UTC](https://community.auth0.com/t/whitelist-and-catch-error-using-google/56030/5 "2021-01-15T18:58:52Z")

</div>

Yes, Rules have access to the [Context](https://auth0.com/docs/rules/context-object) object which contains the `clientMetadata` property as well as other information about your app. You can store key/value pairs of data in your application’s client metadata by opening up the advanced settings in the application settings in the dashboard.

 ![screenshot-manage.auth0.com-2021.01.15-13_55_47](https://global.discourse-cdn.com/auth0/original/3X/8/c/8c82d41224b0e1050dcd5a70534377f859dd2ab4.png)

Or you can use the Management API’s [/api/v2/clients/{id}](https://auth0.com/docs/api/management/v2#!/Clients/patch_clients_by_id) endpoint to add data to the `client_metadata` object.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [January 30, 2021, 6:59pm UTC](https://community.auth0.com/t/whitelist-and-catch-error-using-google/56030/6 "2021-01-30T18:59:02Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
