# Obtaining tokens in server-side component

**URL:** <https://community.auth0.com/t/obtaining-tokens-in-server-side-component/6839>\
**Category:** Get Help\
**Tags:** jwt, serverside, database\
**Created:** [June 1, 2017, 3:22pm UTC](https://community.auth0.com/t/obtaining-tokens-in-server-side-component/6839 "2017-06-01T15:22:06Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![pipsmarketsapp](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/pipsmarketsapp/32/36592_2.png) [@pipsmarketsapp](https://community.auth0.com/u/pipsmarketsapp)\
**Post date:** [June 1, 2017, 3:22pm UTC](https://community.auth0.com/t/obtaining-tokens-in-server-side-component/6839/1 "2017-06-01T15:22:06Z")

</div>

Our customer need to obtain a JWT token from Auth0 on server-side. I assume they need to call `https://{YOUR ACCOUNT}.[eu|au].auth0.com` or similar with username and password?

I assume it something similar to Form POST to `https://app.eu.auth0.com/usernamepassword/login` with `response_type, connection, username, password, client_id`.

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [June 1, 2017, 11:09pm UTC](https://community.auth0.com/t/obtaining-tokens-in-server-side-component/6839/2 "2017-06-01T23:09:07Z")

</div>

The most suitable solution will depend on the exact details, but for example a confidential client like is the case of a server-side component can exchange a username and password for tokens by performing a [resource owner password credentials](https://auth0.com/docs/api-auth/tutorials/password-grant) grant (using the `/oauth/token` endpoint).

Another possibility, if the server-side component can leverage a browser-based flow would be to use the [authorization code](https://auth0.com/docs/api-auth/grant/authorization-code) grant.

Finally and for completeness, if the server-side component in question does not need or is not associated to any notion of end-users then it can make use of [client credentials](https://auth0.com/docs/api-auth/grant/client-credentials) grant as a way to obtain access tokens suitable to call the specified API on behalf of the client application itself

---

<div class="post-metadata">

**Author:** ![pipsmarketsapp](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/pipsmarketsapp/32/36592_2.png) [@pipsmarketsapp](https://community.auth0.com/u/pipsmarketsapp)\
**Post date:** [June 2, 2017, 5:02pm UTC](https://community.auth0.com/t/obtaining-tokens-in-server-side-component/6839/3 "2017-06-02T17:02:31Z")

</div>

I think I misunderstand something. When I look at those examples they either contain

- “client secrets” which means the solution is made on our serverside to protect the client secrets
- “user password” which means our serverside needs to handle the user’s password

Isn’t there a solution where our customer directly connects Auth0 with their username and password to obtain the JWT-token.  
Or should our serverside create a service which handles our customer’s password and connect to Auth0 for a JWT-token which is returned to our customer?

Thanks

---

<div class="post-metadata">

**Author:** ![pipsmarketsapp](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/pipsmarketsapp/32/36592_2.png) [@pipsmarketsapp](https://community.auth0.com/u/pipsmarketsapp)\
**Post date:** [June 2, 2017, 5:02pm UTC](https://community.auth0.com/t/obtaining-tokens-in-server-side-component/6839/4 "2017-06-02T17:02:31Z")

</div>

I think I misunderstand something. When I look at those examples they either contain

- “client secrets” which means the solution is made on our serverside to protect the client secrets
- “user password” which means our serverside needs to handle the user’s password

Isn’t there a solution where our customer directly connects Auth0 with their username and password to obtain the JWT-token.  
Or should our serverside create a service which handles our customer’s password and connect to Auth0 for a JWT-token which is returned to our customer?

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [June 2, 2017, 5:07pm UTC](https://community.auth0.com/t/obtaining-tokens-in-server-side-component/6839/5 "2017-06-02T17:07:53Z")

</div>

Your customer can call `/oauth/token` directly and execute the ROPC grant, however, it will need to do so with information about which client application is performing the call. If you want to restrict the ROPC grant to confidential clients only as an added security measure then the customer would need to have the client secret also. Given you should not be giving client secrets of your own application to third-parties this would imply that you should probably create a client application in specific to represent your customer.

---

<div class="post-metadata">

**Author:** ![pipsmarketsapp](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/pipsmarketsapp/32/36592_2.png) [@pipsmarketsapp](https://community.auth0.com/u/pipsmarketsapp)\
**Post date:** [June 12, 2017, 3:46pm UTC](https://community.auth0.com/t/obtaining-tokens-in-server-side-component/6839/6 "2017-06-12T15:46:33Z")

</div>

Thanks!  
I consider my options. I’m thinking of creating a authorization service my client use to get an access token. The service will keep our secrets.

---

<div class="post-metadata">

**Author:** ![pipsmarketsapp](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/pipsmarketsapp/32/36592_2.png) [@pipsmarketsapp](https://community.auth0.com/u/pipsmarketsapp)\
**Post date:** [June 13, 2017, 12:24am UTC](https://community.auth0.com/t/obtaining-tokens-in-server-side-component/6839/7 "2017-06-13T00:24:44Z")

</div>

Since there’s a single customer using this service I’ve decided to give them my Auth0 client id and secret to use the Authentication API. 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:** [March 2, 2018, 5:54am UTC](https://community.auth0.com/t/obtaining-tokens-in-server-side-component/6839/8 "2018-03-02T05:54:16Z")

</div>


