Describe the problem/error/question
I’m trying to authenticate with the Google Search Console API using the standard HTTP Request node, but I’m running into issues with selecting credentials and also with using the $getCredentials()
function in a Code node as a workaround.
I need to call the GSC API endpoint: POST https://www.googleapis.com/webmasters/v3/sites/[your-gsc-property-id]/searchAnalytics/query
.
Problem 1: Can’t Select Credentials in HTTP Request Node
- I successfully created and connected both a Google OAuth2 API credential (let’s call it
[My OAuth2 Credential]
) and a Google Service Account credential ([My Service Account Credential]
). Both show up correctly in my main n8n Credentials list, and the OAuth2 one shows “Account connected”. - However, when I configure the HTTP Request node:
- If I select
OAuth2
as the Authentication type, the “Credential for OAuth2 API” dropdown below it is empty. My saved credential isn’t listed. - The
Google Service Account
authentication type doesn’t appear as an option in the main Authentication dropdown list at all (even after scrolling).
- If I select
Problem 2: $getCredentials()
Workaround Also Fails
Since direct selection failed, I tried using a Code node before the HTTP Request node to manually fetch the token:
- Using
await $getCredentials('[My OAuth2 Credential]')
failed. The error was"$getCredentials is not defined"
or the function returnednull
for the access token. - Using
await $getCredentials('[My Service Account Credential]')
also failed and returnednull
for the access token (presumably hitting the same underlying issue with$getCredentials
).
Essentially, I seem unable to use either Google credential type with the HTTP Request node, either directly or via the Code node workaround.
What is the error message (if any)?
When trying the Code node workaround, the direct error was: errorMessage: "$getCredentials is not defined"
(when checking the Code node output directly after configuring it to return errors).
Or, the Code node would output gscAccessToken: null
, leading to the subsequent HTTP Request node failing with: Authorization failed - please check your credentials. Request had invalid authentication credentials. Expected OAuth 2 access token...
Share the output returned by the last node
Example output from the GetGscToken
Code node when attempting the manual workaround (shows the function failed to get the token):
[
{
"url": "https://example.com/",
"statusCode": 200,
"title": "Example Page Title",
"metaDescription": null,
"h1": null,
"onpageScore": 95.0,
"redirectUrl": null,
"gscAccessToken": null
}
]
(Or, if using the debug code that returns the error message):
[
{
"credentialNameUsed": "[My Credential Name]",
"rawData": null,
"errorMessage": "$getCredentials is not defined"
}
]
Information on my n8n setup
- n8n version: 1.90.2
- Database (default: SQLite): (Likely default for Cloud)
- n8n EXECUTIONS_PROCESS setting (default: own, main): main (default for Cloud)
- Running n8n via (Docker, npm, n8n cloud, desktop app): n8n cloud
- Operating system: (N/A for Cloud)
Is this a known issue, or is there another way to handle GSC authentication with the HTTP Request node? Thanks for any help!