# How to acquire a Refresh Token in Angular

**URL:** <https://devforum.okta.com/t/how-to-acquire-a-refresh-token-in-angular/14091>\
**Category:** Questions\
**Created:** [May 4, 2021, 9:35pm UTC](https://devforum.okta.com/t/how-to-acquire-a-refresh-token-in-angular/14091 "2021-05-04T21:35:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnstondo](https://avatars.discourse-cdn.com/v4/letter/j/e79b87/32.png) [@johnstondo](https://devforum.okta.com/u/johnstondo)\
**Post date:** [May 4, 2021, 9:35pm UTC](https://devforum.okta.com/t/how-to-acquire-a-refresh-token-in-angular/14091/1 "2021-05-04T21:35:59Z")

</div>

By studying this link: [Get a refresh token | Okta Developer](https://developer.okta.com/docs/guides/refresh-tokens/-/get-refresh-token/#get-a-refresh-token-with-the-code-flow)  
I would like to know how to get the value for the parameter “state”. The bottom line is, I have a JWT and I want to get a new one before the old one expires. I have been trying to use this “authorize” end point as demonstrated at the link above, but so far I have not had any luck. I always get “Unknown Error”.

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [May 4, 2021, 9:51pm UTC](https://devforum.okta.com/t/how-to-acquire-a-refresh-token-in-angular/14091/2 "2021-05-04T21:51:13Z")

</div>

The state parameter is unrelated to the method of getting a refresh token.

I assume you are working on a SPA? We recently rolled out an EA feature that will allow you to enable refresh tokens for SPAs called “Refresh token rotation,” which you should be able to find/enable in the Okta Admin Console under Settings → Features.

With that enabled, you can then also enable the “Refresh token” grant type for the SPA you are working on and start using the offline\_access scope to request refresh tokens on the front end. More details about refresh token rotation [here](https://developer.okta.com/docs/guides/refresh-tokens/refresh-token-rotation/).

[You must use authorization code flow](https://developer.okta.com/docs/reference/api/oidc/#scope-values) ([with PKCE](https://developer.okta.com/docs/guides/implement-auth-code-pkce/overview/) for SPA, [with a Client Secret](https://developer.okta.com/docs/guides/implement-auth-code/overview/) for Web apps with backends handling routes/authorization) in order to get refresh tokens, so you will first need to make a request to the authorize endpoint (you cannot make an AJAX request to this endpoint, you must do a browser redirect) and then take the authorization code returned to the provided redirect\_uri in a request to the /token endpoint to get your tokens. With the above steps followed and offline\_access scope added as a requested scope in your authorize request, you will receive an ID, Access, AND Refresh token in [the response from this endpoint](https://developer.okta.com/docs/reference/api/oidc/#response-properties-2) if your request is successful.

---

<div class="post-metadata">

**Author:** ![johnstondo](https://avatars.discourse-cdn.com/v4/letter/j/e79b87/32.png) [@johnstondo](https://devforum.okta.com/u/johnstondo)\
**Post date:** [May 5, 2021, 3:10pm UTC](https://devforum.okta.com/t/how-to-acquire-a-refresh-token-in-angular/14091/3 "2021-05-05T15:10:13Z")

</div>

Hi Andrea,

Thanks for getting back so quickly.

In regards to, “We recently rolled out an EA feature that will allow you to enable refresh tokens for SPAs called “Refresh token rotation,” which you should be able to find/enable in the Okta Admin Console under Settings → Features.”

When I go to Okta I do not see “Features” under “Settings”. Below I have expanded “Settings”.

![image003.jpg](https://global.discourse-cdn.com/oktadev/original/2X/2/20d8cf429eeba704019e5129d124ed52ae97d2bf.jpeg)

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [May 6, 2021, 4:37pm UTC](https://devforum.okta.com/t/how-to-acquire-a-refresh-token-in-angular/14091/4 "2021-05-06T16:37:44Z")

</div>

You may not have adequate [admin permissions](https://help.okta.com/en/prod/Content/Topics/Security/administrators-admin-comparison.htm) to enable features.

Are you a Super Admin for your Okta tenant? Are you doing this in a Production, Preview, Developer, or Free trial org?

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [February 7, 2024, 12:35am UTC](https://devforum.okta.com/t/how-to-acquire-a-refresh-token-in-angular/14091/5 "2024-02-07T00:35:35Z")

</div>


