If you are into this tech world for a while. I'm sure you heard about the word API. API is Application Program Interface. For example, Google has API which gives user details access to third party softwares. So basically API acts as bridge to pass secure information to authenticate third party softwares. To authenticate this third parties API token is required.
Many contributors use this API tokens to create some unique products like creating Telegram Bot, Slack Bot. Although product was built successfully. Contributors get recognised by showing their code to Dev Community. To do that they need to secure the API token before they publish it to github.
Table of Contents:
Securing API tokens on Windows
Securing API tokens on Github
Securing API tokens on Heroku
Securing API tokens on Windows:
To secure API token you need to define them in the environment variables.
- Search the
Environment Variables
you will find Edit the Environment variables, open it. you will find these Then go to Environment Variables. Click on the New button then add the api token with some variable name and note the variable name
After adding this Variable then Restart it.
Now you can use this API token across any code in your local system.
Securing API tokens on Github:
- First upload your Repo in the GitHub. Open the Your Repo Settings tab as shown below.
Then open Secrets on the left side as shown in above picture.
Then add new Secret with Var name and API token.
Now this variable works across the Repo.
And Secret Variable won't disclose to any other users or third parties by GitHub.
Securing API tokens on Heroku:
In heroku you can do this in two ways either through Heroku CLI or Dashboard.
Heroku CLI
- Open cmd and login to Heroku with
Heroku login
- Go to your Project Folder
- Then use this command
heroku config:set S3_KEY=8N029N81 S3_SECRET=9s83109d3+583493190
Now you can use variable name anywhere in the Project
Heroku DashBoard:
- First Create app in the Heroku
- Goto App settings tab
- Goto Config Vars and add your API tokens
This is it. Hope this post is helpful to you!
If you like my post like it, Share it and if you have a doubt comment down below 👇
Contact me: LinkedIn · GitHub
Top comments (0)