# getTokenSilently / useRefreshTokens / getIdTokenClaims - how to use it correctly?

**URL:** <https://community.auth0.com/t/gettokensilently-userefreshtokens-getidtokenclaims-how-to-use-it-correctly/55619>\
**Category:** Get Help\
**Tags:** auth0\
**Created:** [January 2, 2021, 3:48pm UTC](https://community.auth0.com/t/gettokensilently-userefreshtokens-getidtokenclaims-how-to-use-it-correctly/55619 "2021-01-02T15:48:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shai.maron](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/shai.maron/32/13031_2.png) [@shai.maron](https://community.auth0.com/u/shai.maron)\
**Post date:** [January 2, 2021, 3:48pm UTC](https://community.auth0.com/t/gettokensilently-userefreshtokens-getidtokenclaims-how-to-use-it-correctly/55619/1 "2021-01-02T15:48:34Z")

</div>

Hey,

I have an angular based SPA, and I am completely lost with the documentation.  
I want to use refreshed tokens and I need the claims when calling the backend API.

Do I need to call `getTokenSilently` in interval? or only once? (and what the related configs in auth0 dashboard?)  
Do I need to save the `getTokenSilently` results somewhere?  
When and where should I call `getIdTokenClaims` and Do I need it for refresh token? how I get the refresh token and how do I use it?  
And what is the difference between silent token, ID token and refresh token?

> **[Auth0 Single Page App SDK](https://auth0.com/docs/libraries/auth0-single-page-app-sdk)**
>
> Auth0 SDK for single page applications using Authorization Code Grant Flow with PKCE.

One example from start to end will clarify it, as the documentation share very short example that I cant take to real world app.

Thanks!

---

<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 4, 2021, 8:14pm UTC](https://community.auth0.com/t/gettokensilently-userefreshtokens-getidtokenclaims-how-to-use-it-correctly/55619/3 "2021-01-04T20:14:47Z")

</div>

Hi @shai.maron,

Welcome to the Community!

You may want to take a look at the [Angular QuickStart](https://auth0.com/docs/quickstart/spa/angular/01-login). If you log in and click Download, then the configurations for your application will already be set up in the code. You’ll only need to add `http://localhost:4200` to “ **Allowed Callback URLs** ”, “ **Allowed Web Origins** ”, and “ **Allowed Logout URLs** ” in the application settings.

You can follow along with the tutorial for [login](https://auth0.com/docs/quickstart/spa/angular/01-login) and [calling an API](https://auth0.com/docs/quickstart/spa/angular/02-calling-an-api).

In order to enable the [Refresh Token Rotation](https://auth0.com/docs/tokens/refresh-tokens/refresh-token-rotation/use-refresh-token-rotation) feature, you’ll have to update a couple settings.

In the code of the QuickStart application, in the file `src/environments/environment.ts` add `useRefreshTokens: true,` to the auth environment configurations. It should look like this:

```auto
export const environment = {
  production: false,
  auth: {
    domain,
    clientId,
    audience,
    useRefreshTokens: true,
    redirectUri: window.location.origin,
  },
  httpInterceptor: {
    allowedList: [`${apiUri}/*`],
  },
};

```

In the application settings in your Auth0 dashboard, make sure that Refresh Token Rotation is enabled:

 ![enable-refresh-token-rotation](https://global.discourse-cdn.com/auth0/original/3X/5/9/59d52a9be19514137754b256f8522738a798aca9.png)

Finally, configure your backend API to allow offline access.

 ![API settings](https://global.discourse-cdn.com/auth0/original/3X/a/0/a0f9421a985e1db0011e5497d6af3418aa8fec00.png)

Renewing the Access Token is handled by the SDK. Your application will have access to the user’s profile information and will be able to determine if the user is logged in by using the `auth0-angular` SDK as the auth service, like this:

```auto
import { Component, OnInit } from '@angular/core';
import { AuthService } from '@auth0/auth0-angular';

@Component({
  selector: 'app-profile',
  templateUrl: './profile.component.html',
  styleUrls: ['./profile.component.css'],
})
export class ProfileComponent implements OnInit {
  profileJson: string = null;

  constructor(public auth: AuthService) {}

  ngOnInit() {
    this.auth.user$.subscribe(
      (profile) => (this.profileJson = JSON.stringify(profile, null, 2))
    );
  }
}

```

---

<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 19, 2021, 8:14pm UTC](https://community.auth0.com/t/gettokensilently-userefreshtokens-getidtokenclaims-how-to-use-it-correctly/55619/4 "2021-01-19T20:14:52Z")

</div>

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