Skip to main content

installation

Cloning the Repository​

To use this API, you'll need to have Node.js installed on your system. You can download it from the official website: nodejs.org.

Once you have Node.js installed, you can clone this repository by running the following command:

git clone https://github.com/yourusername/authease.git

After cloning the repository, navigate to the project directory and install the required dependencies:

cd authease
yarn install

Configuration​

Before running the API, you'll need to set up a MongoDB database and provide the database URL and secret in a .env file. To do this, create a new file named .env in the project directory and add the following lines:

ACCESS_TOKEN_PUBLIC_KEY=your-accesstoken-public-key-here
ACCESS_TOKEN_PRIVATE_KEY=your-accesstoken-private-key-here
REFRESH_PRIVATE_KEY=your-refresh-private-key-here
REFRESH_PUBLIC_KEY=your-refresh-public-key-here
DB_URI=your-mongodb-url-here

Replace your-mongodb-url-here with the URL of your MongoDB database and Access Token & Refresh Token Private and public key with your base64 encoded new keys.

Generating Access Token & Refresh Token Private and public keys.​

You can generate new keys here: https://travistidwell.com/jsencrypt/demo/ . Here you can Base64 encode the keys: https://www.base64encode.org/ . You can use the generated base64 encoded keys in your .env file.

MongoDB Database URL​

To get the MongoDB URL for your database, you can follow these steps:

  • Go to the MongoDB website (https://www.mongodb.com/) and click on the "Sign Up" button in the top right corner to create a new account. If you already have an account, log in with your credentials.
  • Once you have logged in, click on the "Clusters" option in the top navigation menu to create a new cluster.
  • Choose a cloud provider, region, and other settings for your cluster.
  • Enter a name for your cluster and select a billing option.
  • Click on "Create Cluster" to create your new cluster. This may take a few minutes.
  • Once your cluster has been created, click on the "Connect" button to obtain the connection string.
  • Select "Connect Your Application" and choose the driver and version you are using for your Node.js application.
  • Copy the connection string provided. The connection string should look something like this:
mongodb+srv://<username>:<password>@<cluster-name>.mongodb.net/<database>?retryWrites=true&w=majority
  • Replace <username> and <password> in the connection string with the credentials you created for your cluster. You can find these in the "Database Access" section of your cluster's settings.
  • Replace <cluster-name> in the connection string with the name of your cluster.
  • Replace <database> in the connection string with the name of the database you want to connect to.
  • Use the modified connection string in your Node.js application's .env file to connect to your MongoDB database.

Note : MongoDB allows you to create multiple database users with different levels of access. Be sure to create a user with appropriate permissions for your application and use its credentials in your connection string.

Running the API​

Once you have set up your database and added the required configuration, you can run the API by executing the following command:

yarn dev

This will start the API on port 3000. You can access the API at http://localhost:3000.

You can also run the API using Docker Compose. To do this, run the following command:

docker-compose up