Yes, n8n fully supports OAuth2 APIs! 🎉 You can connect to any service that uses OAuth2 authentication—whether it's Google, GitHub, Microsoft, or even custom APIs.
✅ How to Use OAuth2 APIs in n8n
Here’s a step-by-step guide:
🔧 1. Create an OAuth2 Credential in n8n
a. Go to:
n8n Dashboard > Credentials > New Credential
b. Choose:
“OAuth2 API” (or the specific integration if available, e.g., “Google OAuth2”)
c. Fill in required fields:
- Client ID
- Client Secret
- Auth URI (e.g.,
https://example.com/oauth/authorize
)
- Access Token URI (e.g.,
https://example.com/oauth/token
)
- Scopes (if required)
- Redirect URI (use the one generated by n8n)
🌐 2. Configure OAuth on the API Provider Side
Register your n8n instance in the API provider’s developer console.
Provide:
- Redirect URI (e.g.,
https://your-n8n.com/rest/oauth2-credential/callback
)
- Allowed scopes (e.g.,
email
, profile
, etc.)
🔄 3. Authorize the Credential
- After saving, click "Connect" on the credential in n8n.
- It will open the OAuth login/consent screen.
- Upon success, n8n stores the access token securely.
📡 4. Use OAuth2 in an HTTP Request
n8n will:
- Automatically attach the token to your request.
- Refresh it when needed (if supported by the API).
🔁 Token Auto-Refresh
If the API supports it, n8n can handle token expiration and refresh automatically via the refresh_token
.
✅ Example: Google API
- Auth URL:
https://accounts.google.com/o/oauth2/auth
- Token URL:
https://oauth2.googleapis.com/token
- Scopes:
https://www.googleapis.com/auth/userinfo.email
- Register your app in Google Developer Console
Let me know which OAuth2 API you want to use, and I can give you a full working example!