# Angular – not able to get the keys

**URL:** <https://community.auth0.com/t/angular-not-able-to-get-the-keys/52618>\
**Category:** Get Help\
**Created:** [November 3, 2020, 7:01am UTC](https://community.auth0.com/t/angular-not-able-to-get-the-keys/52618 "2020-11-03T07:01:57Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![woefienaam](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/woefienaam/32/25379_2.png) [@woefienaam](https://community.auth0.com/u/woefienaam)\
**Post date:** [November 3, 2020, 7:01am UTC](https://community.auth0.com/t/angular-not-able-to-get-the-keys/52618/1 "2020-11-03T07:01:57Z")

</div>

I’m using the Angular SDK.

So, I have been trying for a while now, but my bearer token I’m unable to get, although I see the key in the HTTP-response that is made by, I assume, the interceptor.  
How do I get that key?

 ![autho](https://global.discourse-cdn.com/auth0/original/3X/0/f/0f1ede3d61b601cfd4125b226c89f16cda82786a.png)

Second question, I would like to grape the userID as I want the back end to know who uploaded a file. But how do I get the user ID?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [November 4, 2020, 8:01pm UTC](https://community.auth0.com/t/angular-not-able-to-get-the-keys/52618/3 "2020-11-04T20:01:14Z")

</div>

> [@woefienaam](#):
>
> How do I get that key?

The access token? That is discussed here, it is built on auth0-spa-js which uses the getTokenSilently method.

> **[GitHub - auth0/auth0-angular: Auth0 SDK for Angular Single Page Applications](https://github.com/auth0/auth0-angular#call-an-api)**
>
> Auth0 SDK for Angular Single Page Applications. Contribute to auth0/auth0-angular development by creating an account on GitHub.

> [@woefienaam](#):
>
> Second question, I would like to grape the userID as I want the back end to know who uploaded a file. But how do I get the user ID?

The user id is available in the `sub` claim in the id token. That should be available via the idTokenClaims or the user object in the SDK. Take a look here:

> **[GitHub - auth0/auth0-angular: Auth0 SDK for Angular Single Page Applications](https://github.com/auth0/auth0-angular#display-the-user-profile)**
>
> Auth0 SDK for Angular Single Page Applications. Contribute to auth0/auth0-angular development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![woefienaam](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/woefienaam/32/25379_2.png) [@woefienaam](https://community.auth0.com/u/woefienaam)\
**Post date:** [November 9, 2020, 8:26am UTC](https://community.auth0.com/t/angular-not-able-to-get-the-keys/52618/4 "2020-11-09T08:26:25Z")

</div>

Thanks, but when I make a request to the back-end I cannot access the data. However, if manually add the API key from API explorer in the backend, I can.

import { AuthService } from ‘@auth0/auth0-angular’;

I believe this is how you use the SDK? But Authservice contains isAuthenticated, user$ and one or two other methodes, but not idTokenClaims or anything similar.

So, I’m sure that I’m doing something wrong, but what?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [November 9, 2020, 5:32pm UTC](https://community.auth0.com/t/angular-not-able-to-get-the-keys/52618/5 "2020-11-09T17:32:39Z")

</div>

[`getIdTokenClaims` is mentioned directly in the github readme.](https://github.com/auth0/auth0-angular#access-id-token-claims) Make sure everything is updated.

There shouldn’t be any _API key_. You may be referring to the access token that is available in the dashboard API settings. That token will expire as it is meant to be requested periodically.

[Have you looked at the section that shows how to call an API:](https://github.com/auth0/auth0-angular#call-an-api)

---

<div class="post-metadata">

**Author:** ![woefienaam](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/woefienaam/32/25379_2.png) [@woefienaam](https://community.auth0.com/u/woefienaam)\
**Post date:** [November 9, 2020, 8:23pm UTC](https://community.auth0.com/t/angular-not-able-to-get-the-keys/52618/6 "2020-11-09T20:23:09Z")

</div>

Yes, I did updated it. I used the command “npm install auth0-angular”. The access key I get from get silenttoken doesn’t give me access to my back-end. I really don’t know what I’m doing wrong

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [November 9, 2020, 10:52pm UTC](https://community.auth0.com/t/angular-not-able-to-get-the-keys/52618/7 "2020-11-09T22:52:50Z")

</div>

Are you seeing errors? What do you mean by _it doesn’t give access_.

---

<div class="post-metadata">

**Author:** ![woefienaam](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/woefienaam/32/25379_2.png) [@woefienaam](https://community.auth0.com/u/woefienaam)\
**Post date:** [November 10, 2020, 10:34am UTC](https://community.auth0.com/t/angular-not-able-to-get-the-keys/52618/8 "2020-11-10T10:34:13Z")

</div>

“getSilentTokenkey”, but I do get access with ‘acces-key’ from the API dashboard.  
I don’t have any errors, I have checked the version of Auth0:

 ![afbeelding](https://global.discourse-cdn.com/auth0/original/3X/b/0/b0c8fb7f1fed641f0f9b7cb99d15795b3f059ea3.png)

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [November 10, 2020, 4:23pm UTC](https://community.auth0.com/t/angular-not-able-to-get-the-keys/52618/9 "2020-11-10T16:23:58Z")

</div>

I’m not sure I understand, `getSilentTokenkey` is not a method of either library. It sounds like getTokenSilently. Can you post your code?

Also, you keep saying _keys_…but you are talking about **tokens**.

API **keys** are typically referring to something different than a JWT access **token**. It’s worth mentioning here because it looks like you are trying to use a method that doesn’t exist and mentions keys.

---

<div class="post-metadata">

**Author:** ![woefienaam](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/woefienaam/32/25379_2.png) [@woefienaam](https://community.auth0.com/u/woefienaam)\
**Post date:** [November 10, 2020, 9:18pm UTC](https://community.auth0.com/t/angular-not-able-to-get-the-keys/52618/10 "2020-11-10T21:18:44Z")

</div>

Thanks for your help so far!

So, I’m trying to do this:

 ![Naamloos-2](https://global.discourse-cdn.com/auth0/original/3X/0/a/0acd04e3df8d6e86490aa5d97e50888d0ebc430d.png)

I send a request like this…

 ![afbeelding](https://global.discourse-cdn.com/auth0/original/3X/3/6/3607ee2bcebe4c9d7c180c3b554bb000c3704365.png)

for now the ??? is the key I get from:

 ![afbeelding](https://global.discourse-cdn.com/auth0/original/3X/8/d/8d394bd20e28e4a4fb29ec9e525cd91c4de7be9c.png)

The data from the back-end will only be given with that key, otherwise it wont work.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [November 12, 2020, 11:12pm UTC](https://community.auth0.com/t/angular-not-able-to-get-the-keys/52618/11 "2020-11-12T23:12:11Z")

</div>

It looks like the auth0 angular SDK uses an HTTPinterceptor method to make API calls.

Can you take a look at this section that shows how to make API calls?

> **[Auth0 Angular SDK Quickstarts: Call an API](https://auth0.com/docs/quickstart/spa/angular/02-calling-an-api)**
>
> This tutorial demonstrates how to make API calls to the Auth0 Management API.

I’m not really familiar with the angular way of doing things, but it looks like this is a common schema.

---

<div class="post-metadata">

**Author:** ![woefienaam](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/woefienaam/32/25379_2.png) [@woefienaam](https://community.auth0.com/u/woefienaam)\
**Post date:** [November 13, 2020, 6:11am UTC](https://community.auth0.com/t/angular-not-able-to-get-the-keys/52618/12 "2020-11-13T06:11:45Z")

</div>

I will. But quick question: my idea is that the bearer token is given by the front-end to the backend, but somebody says the front-end and backend use a JWT-token and the bearer-token stays on the back-end.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [November 13, 2020, 4:35pm UTC](https://community.auth0.com/t/angular-not-able-to-get-the-keys/52618/13 "2020-11-13T16:35:12Z")

</div>

JWT could be a bearer token.

It seems like you have a lot of questions and confusion about the fundamentals of authentication. I would encourage you to read through documentation before asking questions, as some of these concepts are difficult to grasp without an overall picture of how the flows are working.

This is a good place to start if you are new to authentication.

> **[OAuth 2.0 Authorization Framework](https://auth0.com/docs/authenticate/protocols/oauth)**
>
> Learn how Auth0 works with the OAuth 2.0 Authorization Framework.

---

<div class="post-metadata">

**Author:** ![woefienaam](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/woefienaam/32/25379_2.png) [@woefienaam](https://community.auth0.com/u/woefienaam)\
**Post date:** [November 19, 2020, 1:14pm UTC](https://community.auth0.com/t/angular-not-able-to-get-the-keys/52618/14 "2020-11-19T13:14:44Z")

</div>

I did. It works. Thanks!

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [November 19, 2020, 4:39pm UTC](https://community.auth0.com/t/angular-not-able-to-get-the-keys/52618/15 "2020-11-19T16:39:57Z")

</div>

Glad to hear it! Thanks!

---

<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:** [December 4, 2020, 4:40pm UTC](https://community.auth0.com/t/angular-not-able-to-get-the-keys/52618/16 "2020-12-04T16:40:00Z")

</div>

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