In this section
Using Node.js to get Bearer Token
On this page we will give you a small example of the Node,js code and the creation of the Node.js file/folder.
The Node.js can be used as an alternative way of getting the Bearer Token instead of using the C# method. The principle behind is the same execept one attribute needs to be added, since that has been confined within the class that is beign used in the C#. This attribute is the "secret" which has the value "secret" behind it.
To create the Node.js structure and the needed packages, we advise you to create a folder on the same level as the highest ranked folder of your react project. With the file explorer you will enter said folder and open the command console within that folder. Then you will type "npm init -y" in the command console. This will generate the package-files. Afterwads create a new folder and add a JS file. In our case we call index.js.
In the example shown below, we have also included two examples of creating the normal API calls. This allows you to have added security as you dont show the bearer token which could be used in a malicous way from the 3rd party users. Therefore we determine it to be important to never show the berarer token to the user in case there is a power user lurking around. You can always create a second ticketino.com account and assign only the needed writes, without giving him any editing power of your events or intrusive sights in the statistics.
Within said file we will insert the following code. You can now access the newly created API on the determined url. In our case https://localhost:3001/token, since we dont have anything else defined in the .env file.