# How to get token from a nodejs application

**URL:** <https://community.auth0.com/t/how-to-get-token-from-a-nodejs-application/86322>\
**Category:** Get Help\
**Tags:** jwt, api, auth0\
**Created:** [July 3, 2022, 6:20am UTC](https://community.auth0.com/t/how-to-get-token-from-a-nodejs-application/86322 "2022-07-03T06:20:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![montassar](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/montassar/32/33313_2.png) [@montassar](https://community.auth0.com/u/montassar)\
**Post date:** [July 3, 2022, 6:20am UTC](https://community.auth0.com/t/how-to-get-token-from-a-nodejs-application/86322/1 "2022-07-03T06:20:49Z")

</div>

hello,  
I developed a slack application and it contains some axios requests that require the silent token and some information about the user (like his email). also, it opens the login popup if the user is not authenticated.  
all of that seems impossible in an API application with no web interface.  
can someone tell me if there is a solution for this ?

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [July 8, 2022, 1:06am UTC](https://community.auth0.com/t/how-to-get-token-from-a-nodejs-application/86322/3 "2022-07-08T01:06:55Z")

</div>

Hey there @montassar !

> [@montassar](#):
>
> all of that seems impossible in an API application with no web interface.  
> can someone tell me if there is a solution for this ?

Regarding the API application with no web interface… I assume there is no user involved? If that is the case, I recommend taking a look at the following documentation regarding machine to machine (M2M) applications:

> **[Using Machine to Machine (M2M) Authorization](https://auth0.com/blog/using-m2m-authorization/)**
>
> How to set up non-interactive apps using the client credentials grant and Auth0 to perform IoT device, CLI tool, and more machine to mach...

> **[Client Credentials Flow](https://auth0.com/docs/get-started/authentication-and-authorization-flow/client-credentials-flow)**
>
> Learn how the Client Credentials flow works and why you should use it for machine-to-machine (M2M) applications.

> **[Register Machine-to-Machine Applications](https://auth0.com/docs/get-started/auth0-overview/create-applications/machine-to-machine-apps)**
>
> Learn how to register and configure a machine-to-machine (M2M) application using the Auth0 Dashboard and authorize it using the Management API test feature.

Hope this helps get you headed in the correct direction 😄

---

<div class="post-metadata">

**Author:** ![montassar](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/montassar/32/33313_2.png) [@montassar](https://community.auth0.com/u/montassar)\
**Post date:** [July 8, 2022, 6:36am UTC](https://community.auth0.com/t/how-to-get-token-from-a-nodejs-application/86322/4 "2022-07-08T06:36:18Z")

</div>

hello @ty.frith,  
I really appreciate your reply. But i still have one more question.  
My application has no web interface but it still has to redirect the user to auth0 authentication page and he still needs to pass his email and password in order to login to his account.  
in this case, does my application need a M2M application or a regular we application ?

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [July 8, 2022, 4:58pm UTC](https://community.auth0.com/t/how-to-get-token-from-a-nodejs-application/86322/5 "2022-07-08T16:58:24Z")

</div>

Happy to help!

> [@montassar](#):
>
> he still needs to pass his email and password in order to login to his account.

If there is a user involved then it will need to be a regular web app - Is the goal to receive an access token/id token specific to the user involved?

Let us know!

Further, I definitely recommend checking out our documentation on common architecture scenarios here:

> **[Architecture Scenarios](https://auth0.com/docs/get-started/architecture-scenarios)**
>
> Learn about common Auth0 architecture scenarios that you can use to solve your authorization and authentication needs.

---

<div class="post-metadata">

**Author:** ![montassar](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/montassar/32/33313_2.png) [@montassar](https://community.auth0.com/u/montassar)\
**Post date:** [July 9, 2022, 4:11pm UTC](https://community.auth0.com/t/how-to-get-token-from-a-nodejs-application/86322/6 "2022-07-09T16:11:58Z")

</div>

yes, our user needs to login via auth0 before using our application (it has no web interface). the goal is to receive an access/id token and his user information, because some requests to our database require his email or nickname …

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [July 15, 2022, 11:24pm UTC](https://community.auth0.com/t/how-to-get-token-from-a-nodejs-application/86322/7 "2022-07-15T23:24:41Z")

</div>

> [@montassar](#):
>
> yes, our user needs to login via auth0 before using our application (it has no web interface)

How exactly is the user to log in if there is no interface? I guess I am confused by the use case here. Will you already have the user info to log in with? Your estimation may be correct in that there might not be a solution for a use case where there is a user involved, but no way to collect information or interact with them.

---

<div class="post-metadata">

**Author:** ![montassar](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/montassar/32/33313_2.png) [@montassar](https://community.auth0.com/u/montassar)\
**Post date:** [July 16, 2022, 6:46am UTC](https://community.auth0.com/t/how-to-get-token-from-a-nodejs-application/86322/8 "2022-07-16T06:46:06Z")

</div>

hi @ty.frith ,  
well it’s a slack application, slack is a desktop app and we are building a chat bot on it where the user can make requests and receive responses. the only interface the user interacts with, is the slack desktop app interface. but before using it, he has to authenticate via auth0 and we has to take and receive his token in order to authorize his requests

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [July 31, 2022, 6:46am UTC](https://community.auth0.com/t/how-to-get-token-from-a-nodejs-application/86322/9 "2022-07-31T06:46:55Z")

</div>

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