# Your Examples "Angular 2+ Login" and "Angular 2+ Calling an API" Clarification

**URL:** <https://community.auth0.com/t/your-examples-angular-2-login-and-angular-2-calling-an-api-clarification/9511>\
**Category:** Get Help\
**Tags:** auth0-endpoint-jwt\
**Created:** [February 15, 2018, 10:38pm UTC](https://community.auth0.com/t/your-examples-angular-2-login-and-angular-2-calling-an-api-clarification/9511 "2018-02-15T22:38:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gerald.bauer](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gerald.bauer/32/8610_2.png) [@gerald.bauer](https://community.auth0.com/u/gerald.bauer)\
**Post date:** [February 15, 2018, 10:38pm UTC](https://community.auth0.com/t/your-examples-angular-2-login-and-angular-2-calling-an-api-clarification/9511/1 "2018-02-15T22:38:14Z")

</div>

Your Examples “Angular 2+ Login” (example 1) and “Angular 2+ Calling an API” (example 2) are GREAT thank you! They are extremely helpful and your documentation is really good! I have some question regarding the audience property when using the method auth0.WebAuth.

In example 1, the audience value is `https://${AUTH_CONFIG.domain}/userinfo`. Whereas example 2 uses `AUTH_CONFIG.apiUrl` ([https://services.mycompanyname.com](https://services.mycompanyname.com)). Both authenticate as expected. When using example 1’s endpoint I am getting the following message: “Error: JWT must have 3 parts” which is perplexing. My assumption is that the two endpoints are returning similar but different JWT. My underlying question is which audience property value (aka endpoint) should I use - example 1 or example 2? Or, is there another one that is better? (Right now I am thinking example 2 since it is returning well formed JWT.)

By the way, I am using another great documented example “[ASP.NET](http://ASP.NET) Core Web API Authorization.” I needed to make some tweaks when using this example with “Angular 2+ Calling an API.” My first change was the API port number within the UI to match what was found in the [ASP.NET](http://ASP.NET) API project. Second I had to add UseCors to the API so that the two examples could communicate.

---

<div class="post-metadata">

**Author:** ![ricardo.batista](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ricardo.batista/32/7711_2.png) [@ricardo.batista](https://community.auth0.com/u/ricardo.batista)\
**Post date:** [February 15, 2018, 11:14pm UTC](https://community.auth0.com/t/your-examples-angular-2-login-and-angular-2-calling-an-api-clarification/9511/2 "2018-02-15T23:14:48Z")

</div>

When specifying the audience in your authentication request, you’re following the [OIDC-conformant authentication pipeline](https://auth0.com/docs/api-auth/tutorials/adoption). As stated in the [documentation] ([OpenID Connect Protocol](https://auth0.com/docs/api-auth/tutorials/adoption#terminology)), this pipeline will be used if any of the following are true:

- An authentication request was  
initiated with an audience parameter.
- The client being used is flagged as  
OIDC Conformant (available at  
Dashboard \> Clients \> Settings \> Show  
advanced settings \> OAuth \> OIDC  
Conformant flag).

In your examples, the first is using `https://{YOUR_AUTH0_DOMAIN}/userinfo`as the audience and the second is using a custom API, `https://services.mycompanyname.com` in this case.

In the [access token documentation] ([https://auth0.com/docs/tokens/access-token#access-token-format](https://auth0.com/docs/tokens/access-token#access-token-format)) you can see that:

- If the audience is set to  
{YOUR\_AUTH0\_DOMAIN}/userinfo, then  
the Access Token will be an opaque  
string.
- If the audience is set to the unique  
identifier of a custom API, then the  
Access Token will be a JSON Web Token  
(JWT).

So in the first example, the access token will be an opaque string (something like ´KsIAlfgfaaa3NbFae5vwdAy1pEd7GNNF´), which is not a JWT, and will fail with the “Error: JWT must have 3 parts” message if you try to use it where a JWT is necessary. Keep in mind that since you specified /userinfo as the audience, you’ll still be able to call the [/userinfo endpoint] ([Authentication API Explorer](https://auth0.com/docs/api/authentication#get-user-info)) with that access token. If you use a custom API as the audience, you’ll get a [JSON Web Token](https://auth0.com/docs/jwt), which consists of three parts separated by dots (.), which are:

- Header
- Payload
- Signature

Therefore, a JWT typically looks like: `xxxxx.yyyyy.zzzzz`

---

<div class="post-metadata">

**Author:** ![gerald.bauer](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gerald.bauer/32/8610_2.png) [@gerald.bauer](https://community.auth0.com/u/gerald.bauer)\
**Post date:** [February 15, 2018, 11:21pm UTC](https://community.auth0.com/t/your-examples-angular-2-login-and-angular-2-calling-an-api-clarification/9511/3 "2018-02-15T23:21:02Z")

</div>

Wonderful! Thank you for that explanation.

---

<div class="post-metadata">

**Author:** ![gerald.bauer](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gerald.bauer/32/8610_2.png) [@gerald.bauer](https://community.auth0.com/u/gerald.bauer)\
**Post date:** [February 15, 2018, 11:26pm UTC](https://community.auth0.com/t/your-examples-angular-2-login-and-angular-2-calling-an-api-clarification/9511/4 "2018-02-15T23:26:02Z")

</div>

Wonderful! Thank you for clarifying.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [July 25, 2019, 10:07am UTC](https://community.auth0.com/t/your-examples-angular-2-login-and-angular-2-calling-an-api-clarification/9511/5 "2019-07-25T10:07:44Z")

</div>


