n8n is an open-source workflow automation tool that lets you connect apps, APIs, and databases without heavy coding. To make these connections work, you need credentials – secure ways to prove your identity to services like Google, Facebook, Linkedin, or a custom API.
This beginner-friendly guide explains what n8n credentials are, how to set up n8n for the first time, and how to run your first credential-based workflow.
What Are n8n Credentials?
Credentials in n8n are the login or access details you provide so workflows can talk to external services. Think of them as digital keys. Without them, your workflow cannot fetch data, post updates, or trigger events.
Why n8n credentials are required in workflows
- They authenticate requests to APIs.
- They protect sensitive data from being exposed.
- They allow multiple users to safely share workflows without sharing passwords.
Types of n8n credentials
- API Key: A unique token you copy from a service and paste into n8n (e.g., OpenWeather API).
- OAuth2: A secure handshake used by platforms like Google, Facebook, and x.com.
- Custom Credentials: For private APIs or unusual authentication methods.
Preparing Your Environment
Before adding credentials, you need a working n8n environment.
Installing n8n
You can run n8n in three common ways:
- n8n Cloud – hosted by the official team, no setup needed.
- Local installation (npm) – install using Node.js and run on your computer.
npm install n8n -g
n8n start
- Docker installation – best for production setups.
docker run -it –rm \
-p 5678:5678 \
-v ~/.n8n:/home/node/.n8n \
n8nio/n8n
Pro Tip: Quick Alternative with Free Credits: If you don’t want to manage hosting yourself, you can also use:
- Free $5 every month with quick GitHub verification.
- 50% off yearly Hobby & Pro plans (until Oct-31).
- No credit card needed, setup in under 1 minute.
Environment variables and configuration basics
- Environment variables are key-value pairs stored outside your code.
- Commonly used in .env files for sensitive credentials.
- Example:
• N8N_BASIC_AUTH_USER=admin
• N8N_BASIC_AUTH_PASSWORD=securePass
Adding Credentials in n8n
Using the n8n UI (step-by-step)
- Open your n8n editor at http://localhost:5678 or your hosted URL.
- Go to Credentials in the left-hand menu.
- Click New Credential and choose the service (e.g., Google Sheets, Slack).
- Enter your API key, client ID, or OAuth details.
- Save and test.
Setting API keys securely
- Always copy API keys from your provider’s developer dashboard.
- Store them in environment variables instead of hardcoding.
OAuth2 flow in n8n
- Select OAuth2 when creating credentials.
- Provide client ID, secret, and redirect URL
- Approve access in the popup window.
Example: First Workflow with Credentials
Connect to a Public API (OpenWeather Example)
Let’s walk through a simple workflow that fetches live weather data using the OpenWeather API.
- Go to OpenWeather and create a free account.
- Generate your API key from the dashboard.
- In n8n, create a new credential:
o Type: HTTP Request
o Authentication: Header Auth with API key (or use environment variables for security). - Create a workflow with the following nodes:
o Cron Node → triggers workflow every hour.
o HTTP Request Node → fetches data from OpenWeather.
o Function Node → parses the JSON response.
o Google Sheets or Email Node → outputs the weather info.
Test and Debug Credentials
- Click Execute Workflow in n8n.
- If the API key is valid, you’ll see a JSON response with weather details (temperature, humidity, condition).
- Common fixes:
- Ensure you copied the API key correctly.
- If you see a 401 Unauthorized, the API key may be invalid or missing.
- Check that you used HTTPS in the request URL.
Try This JSON Workflow
You can import the workflow below into your n8n editor and add your API key.
{
“name”: “Weather Fetch Example”,
“nodes”: [
{
“parameters”: {
“triggerTimes”: [
{
“hour”: 9,
“minute”: 0
}
]
},
“name”: “Cron”,
“type”: “n8n-nodes-base.cron”,
“typeVersion”: 1,
“position”: [250, 300]
},
{
“parameters”: {
“url”: “https://api.openweathermap.org/data/2.5/weather?q=London&appid={{$env.OPENWEATHER_API_KEY}}&units=metric”,
“responseFormat”: “json”
},
“name”: “HTTP Request”,
“type”: “n8n-nodes-base.httpRequest”,
“typeVersion”: 2,
“position”: [500, 300],
“credentials”: {
“httpBasicAuth”: {
“id”: “your-credential-id”,
“name”: “OpenWeather API”
}
}
},
{
“parameters”: {
“functionCode”: “return [{json: {temp: $json.main.temp, condition: $json.weather[0].description}}];”
},
“name”: “Function”,
“type”: “n8n-nodes-base.function”,
“typeVersion”: 1,
“position”: [750, 300]
},
{
“parameters”: {
“operation”: “append”,
“sheetId”: “your-google-sheet-id”,
“range”: “Sheet1!A:C”,
“valueInputMode”: “USER_ENTERED”,
“options”: {}
},
“name”: “Google Sheets”,
“type”: “n8n-nodes-base.googleSheets”,
“typeVersion”: 2,
“position”: [1000, 300],
“credentials”: {
“googleApi”: {
“id”: “your-credential-id”,
“name”: “Google API”
}
}
}
],
“connections”: {
“Cron”: {
“main”: [
[
{
“node”: “HTTP Request”,
“type”: “main”,
“index”: 0
}
]
]
},
“HTTP Request”: {
“main”: [
[
{
“node”: “Function”,
“type”: “main”,
“index”: 0
}
]
]
},
“Function”: {
“main”: [
[
{
“node”: “Google Sheets”,
“type”: “main”,
“index”: 0
}
]
]
}
}
}
Tip: Save your API key in an .env file as OPENWEATHER_API_KEY for better security, then reference it in the request URL as shown above.
Alternative: Send Weather Update by Email
If you prefer getting updates by email, you can use this workflow. Just configure your Email credentials (Gmail, SMTP, or Outlook) in n8n.
{
“name”: “Weather Email Example”,
“nodes”: [
{
“parameters”: {
“triggerTimes”: [
{
“hour”: 9,
“minute”: 0
}
]
},
“name”: “Cron”,
“type”: “n8n-nodes-base.cron”,
“typeVersion”: 1,
“position”: [250, 300]
},
{
“parameters”: {
“url”: “https://api.openweathermap.org/data/2.5/weather?q=London&appid={{$env.OPENWEATHER_API_KEY}}&units=metric”,
“responseFormat”: “json”
},
“name”: “HTTP Request”,
“type”: “n8n-nodes-base.httpRequest”,
“typeVersion”: 2,
“position”: [500, 300],
“credentials”: {
“httpBasicAuth”: {
“id”: “your-credential-id”,
“name”: “OpenWeather API”
}
}
},
{
“parameters”: {
“functionCode”: “return [{json: {subject: ‘Daily Weather Report’, body: `The current temperature is ${$json.main.temp}°C with ${$json.weather[0].description}.`}}];”
},
“name”: “Function”,
“type”: “n8n-nodes-base.function”,
“typeVersion”: 1,
“position”: [750, 300]
},
{
“parameters”: {
“fromEmail”: “your-email@example.com”,
“toEmail”: “receiver@example.com”,
“subject”: “={{$json[\”subject\”]}}”,
“text”: “={{$json[\”body\”]}}”
},
“name”: “Email”,
“type”: “n8n-nodes-base.emailSend”,
“typeVersion”: 1,
“position”: [1000, 300],
“credentials”: {
“smtp”: {
“id”: “your-email-credential-id”,
“name”: “Email Account”
}
}
}
],
“connections”: {
“Cron”: {
“main”: [
[
{
“node”: “HTTP Request”,
“type”: “main”,
“index”: 0
}
]
]
},
“HTTP Request”: {
“main”: [
[
{
“node”: “Function”,
“type”: “main”,
“index”: 0
}
]
]
},
“Function”: {
“main”: [
[
{
“node”: “Email”,
“type”: “main”,
“index”: 0
}
]
]
}
}
}
How it works
- Cron Node → runs daily at 9:00 AM.
- HTTP Request Node → fetches weather data from OpenWeather.
- Function Node → formats the data into a message.
- Email Node → sends the weather report to your inbox.
Managing Credentials Securely
Using environment variables for sensitive data
Example in .env:
• OPENWEATHER_API_KEY=12345abc
In n8n, reference it as {{$env.OPENWEATHER_API_KEY}}.
Role of .env files and Docker secrets
- .env files simplify local development.
- For production: use Docker secrets or secure vaults like AWS Secrets Manager.
Common mistakes to avoid
- Hardcoding API keys inside nodes.
- Sharing workflows without removing sensitive credentials.
- Using the same credentials for dev and production.
Troubleshooting n8n Credentials & Setup
Invalid API keys
- Double-check for extra spaces.
- Confirm your subscription tier supports the request.
Expired OAuth tokens
- Some tokens expire in hours. Enable token refresh in n8n.
Docker environment variable issues
- Verify .env is mounted into the container.
- Use docker-compose.yml for persistent setups.
Best Practices for Beginners
- Keep secrets in environment variables, not in workflows.
- Use role-based access if multiple users share the same n8n instance.
- Document your credentials usage (service, scope, expiry).
- Separate development credentials from production credentials.
This guide covered the essentials of n8n credentials and how to use them safely in your first workflows. In short: credentials are the keys that let n8n talk to external services, so treat them as sensitive data — store them outside your workflow, limit their scope, and separate development and production credentials.
Next steps
- Import one of the JSON workflows above into your n8n editor.
- Add your API key (for example, OPENWEATHER_API_KEY) in an .env file or in n8n’s credential entry.
- Execute the workflow and check the node output to confirm the data is flowing.
If you prefer managed hosting, consider the RunClaw option mentioned earlier for quick setup and monthly credits (optional).
Quick checklist (before you go live)
- Store secrets in environment variables or a secrets manager (not in nodes).
- Use separate credentials for dev and prod.
- Limit credential scopes and rotate keys regularly (for example, every 90 days).
- Use role-based access when multiple people use the same n8n instance.
- Monitor logs and test refresh/expiry flows for OAuth credentials.
Some helpful resource for n8n credentials
n8n Documentation | OpenWeather API Docs | Docker Documentation
Some Free Tools
Image to Text Tool | SEO Tools Collection
FAQs for n8n credentials
Q1: What are n8n credentials used for?
A: They authenticate workflows with external services like Google, Slack, or APIs, ensuring secure and successful requests.
2: Can I use the same credentials across workflows?
A: Yes, n8n allows credentials to be reused across multiple workflows, reducing duplication.
3: Where are my n8n credentials stored?
A: By default, credentials are encrypted and stored in the n8n database. Encryption keys come from environment variables.
4: Is it safe to share workflows containing credentials?
A: No. Always export workflows without credentials or use placeholder variables.
5: Do I need Docker to run n8n with credentials?
A: Not strictly. You can run n8n locally or on cloud, but Docker is recommended for secure production setups.
6: How do I rotate expired credentials?
A: Edit the credential entry in n8n, update the API key or OAuth details, and save. Existing workflows will use the updated credential.