# Use encodeToken to generate a token signed with RS256

**URL:** <https://community.auth0.com/t/use-encodetoken-to-generate-a-token-signed-with-rs256/88251>\
**Category:** Get Help\
**Created:** [August 5, 2022, 6:29am UTC](https://community.auth0.com/t/use-encodetoken-to-generate-a-token-signed-with-rs256/88251 "2022-08-05T06:29:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomas4](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@tomas4](https://community.auth0.com/u/tomas4)\
**Post date:** [August 5, 2022, 6:29am UTC](https://community.auth0.com/t/use-encodetoken-to-generate-a-token-signed-with-rs256/88251/1 "2022-08-05T06:29:17Z")

</div>

Hi, I am trying to use `api.redirect.encodeToken` inside an action to encode my token and then send it via `sendUserTo`. I want to use RS256.

Here is a sample of the code

```auto
  const token = api.redirect.encodeToken({
    secret: event.secrets.SECRET_KEY,
    expiresInSeconds: 120,
    payload: {
      // Custom claims to be added to the token
      email: event.user.email,
    },
  });

```

For the SECRET KEY I am using a RS256 key that I am using in other parts of my app. It works fine anywhere else (validating it with jose).

The problem is, when I decode the token that is generated by the action, its always HS256

 ![image](https://global.discourse-cdn.com/auth0/original/3X/6/d/6d1a964aba16b38c835f06ccc7d0a932ba6589e7.png)

Checking the OAuth settings of my app settings I can see its set to RS256 ( and the access token and id\_token are both signed with RS256).

I guess the question is, what am I doing wrong or is there any way to sign with RS256 the tokens generated by actions?

I can always import jose and create my own token manually but would love to avoid it

---

<div class="post-metadata">

**Author:** ![thameera](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/thameera/32/13430_2.png) [@thameera](https://community.auth0.com/u/thameera)\
**Post date:** [August 5, 2022, 7:32am UTC](https://community.auth0.com/t/use-encodetoken-to-generate-a-token-signed-with-rs256/88251/2 "2022-08-05T07:32:39Z")

</div>

Hey @tomas4, the `encodeToken` function signs the token with [an HS256 signature](https://auth0.com/docs/customize/actions/flows-and-triggers/login-flow/redirect-with-actions#pass-information-back-to-the-action). It does not support RS256. The secret you pass to it is just a secret key/passphrase, and not an RS256 key. The same secret should be used in the application to validate the token.

If you’d like the token to be signed with RS256, you’ll need to import an npm module like `jsonwebtoken` and use its methods.

---

<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:** [November 4, 2022, 2:47pm UTC](https://community.auth0.com/t/use-encodetoken-to-generate-a-token-signed-with-rs256/88251/3 "2022-11-04T14:47:22Z")

</div>


