I’m building an OAuth onboarding flow in n8n 2.4.5 (self-hosted) where clients connect their Google Calendar via a webhook link. OAuth itself works (I get the code, exchange it for tokens successfully), but I’m stuck at programmatically creating the credential.
I’m using the n8n node → Resource: Credential → Operation: Create with credential type googleCalendarOAuth2Api.
No matter what I pass into the Data field, I keep getting:
The ‘data’ property must be valid JSON, but cannot be parsed
This happens even when the value is a simple hard-coded JSON string.
What I’ve tried
Using JSON.stringify({…}) in expression mode
Returning a literal JSON string via concatenation
Hard-coding values (no variables)
Verified the node is using a valid n8nApi credential
The error is thrown inside the n8n node, not the REST API
Current node configuration (simplified)
Create a credential node
Resource: credential
Operation: create
Credential Type Name: googleCalendarOAuth2Api
Name:
={{ $json.credentialName }}
Data (expression mode):
={{ ‘{’
- ‘“clientId”:“379116820638-bi3gh2cnpsc8q96edkhv57oan7lb2b6a.apps.googleusercontent.com”,’
- ‘“clientSecret”:“GOCSPX-XXXXX”,’
- ‘“scope”:“https://www.googleapis.com/auth/calendar”’
- ‘}’ }}
Still fails with the same parse error.
Questions
What exact format does the data field expect in the n8n “Create credential” node for googleCalendarOAuth2Api?
Is this node not meant to be used for OAuth credentials programmatically?
Is there a known bug / limitation in n8n 2.x with this node?
Has anyone successfully created OAuth credentials via this node, or is using /rest/credentials the only reliable approach?
Any insight from someone who has actually done this would be appreciated.
I’m intentionally avoiding the REST API unless the node is fundamentally broken.
Describe the problem/error/question
What is the error message (if any)?The ‘data’ property must be valid JSON, but cannot be parsed
Please share your workflow
Share the output returned by the last node
“expires_in”:
3599,
“access_token”:
“ya29.a0AUMWg_JfP9cza-XWWzQR6LVLc37jyHU22lgLpegwZmxsUdCRbskT9B0XK-Jd6gsK5yOt…”,
“refresh_token”:
“1//03X8LISNwF-L9IrYiiiVC-PRjJbuCDduk6YPOSWXR9yn…”,
“token_type”:
“Bearer”,
“scope”:
“https://www.googleapis.com/auth/calendar”,
“credentialName”:
“undefined_GoogleCalendar_20260123145203”
Information on your n8n setup
- n8n version: 2.4.5.
- Database (default: SQLite):
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- Running n8n via (Docker, npm, n8n cloud, desktop app): cloud (hostinger)
- Operating system: