# How to share or reuse secrete key in two or more java servers

**URL:** <https://community.auth0.com/t/how-to-share-or-reuse-secrete-key-in-two-or-more-java-servers/38487>\
**Category:** JWT.io\
**Tags:** jwt, auth0\
**Created:** [February 26, 2020, 7:17am UTC](https://community.auth0.com/t/how-to-share-or-reuse-secrete-key-in-two-or-more-java-servers/38487 "2020-02-26T07:17:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mallikarjuna023](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mallikarjuna023/32/19422_2.png) [@mallikarjuna023](https://community.auth0.com/u/mallikarjuna023)\
**Post date:** [February 26, 2020, 7:17am UTC](https://community.auth0.com/t/how-to-share-or-reuse-secrete-key-in-two-or-more-java-servers/38487/1 "2020-02-26T07:17:39Z")

</div>

Hi, I am generating key like below  
public static final Key key = Keys.secretKeyFor(SignatureAlgorithm.HS256);

each time when I am running java application, a new key is generated . and doing authorization based on that. this is working fine, but we have one problem, we have totally 3 backend servers and one reactjs front end server for our application. If I generate Token in one server I could not reuse the same in other servers. I need you to support to understand better this one and how can i build a common token validation mechanism to validate all incoming API requests in all 3 servers.

---

<div class="post-metadata">

**Author:** ![mathiasconradt](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mathiasconradt/32/12758_2.png) [@mathiasconradt](https://community.auth0.com/u/mathiasconradt)\
**Post date:** [February 26, 2020, 7:43am UTC](https://community.auth0.com/t/how-to-share-or-reuse-secrete-key-in-two-or-more-java-servers/38487/2 "2020-02-26T07:43:36Z")

</div>

Why not use RS256, it’s recommended over HS256?

> **[Signing Algorithms](https://auth0.com/docs/get-started/applications/signing-algorithms)**
>
> Describes signing algorithms and recommendations for configuring them in the Auth0 Dashboard.

> [@JWT signing algorithms RS256 vs HS256](http://community.auth0.com/t/jwt-signing-algorithms-rs256-vs-hs256/7720):
>
> Are there any requirements/recommendations/best practices for choosing one over the other? Thank you.

---

<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:** [February 26, 2020, 1:04pm UTC](https://community.auth0.com/t/how-to-share-or-reuse-secrete-key-in-two-or-more-java-servers/38487/3 "2020-02-26T13:04:19Z")

</div>

Yep can you let us know our concerns @mallikarjuna023?
