# googleOAuth2Api Credentials overwrites doesn't work

**URL:** <https://community.n8n.io/t/googleoauth2api-credentials-overwrites-doesnt-work/8589>\
**Category:** Questions\
**Tags:** credentials\
**Created:** [October 20, 2021, 10:14am UTC](https://community.n8n.io/t/googleoauth2api-credentials-overwrites-doesnt-work/8589 "2021-10-20T10:14:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Madriax](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/madriax/32/6946_2.png) [@Madriax](https://community.n8n.io/u/Madriax)\
**Post date:** [October 20, 2021, 10:14am UTC](https://community.n8n.io/t/googleoauth2api-credentials-overwrites-doesnt-work/8589/1 "2021-10-20T10:14:45Z")

</div>

Hello,

When I try to overwrite my credentials for googleOAuth2Api using the environment variable, it doesn’t work. But when I try to overwrite credentials for a single Google tool such as googleSheetsOAuth2Api using the same technique, it’s working.

Here’s the value I set for the environment variable:  
`CREDENTIALS_OVERWRITE_DATA='{"googleOAuth2Api":{"clientId":"xxx","clientSecret":"xxx"}}'`

N8N Version: 0.144.0

---

<div class="post-metadata">

**Author:** ![harshil1712](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/harshil1712/32/1374_2.png) [@harshil1712](https://community.n8n.io/u/harshil1712)\
**Post date:** [October 20, 2021, 11:28am UTC](https://community.n8n.io/t/googleoauth2api-credentials-overwrites-doesnt-work/8589/2 "2021-10-20T11:28:29Z")

</div>

Hey @Madriax,

This is expected behavior. Each Google node has its own scopes that are required for authentication. They use different credentials for authentication. You can these files here: [n8n/packages/nodes-base/credentials at master · n8n-io/n8n · GitHub](https://github.com/n8n-io/n8n/tree/master/packages/nodes-base/credentials)

---

<div class="post-metadata">

**Author:** ![Madriax](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/madriax/32/6946_2.png) [@Madriax](https://community.n8n.io/u/Madriax)\
**Post date:** [October 20, 2021, 11:37am UTC](https://community.n8n.io/t/googleoauth2api-credentials-overwrites-doesnt-work/8589/3 "2021-10-20T11:37:24Z")

</div>

Hi @harshil1712

Here is what it is said in the documentation

> There are cases when credentials are based on others. For example, the `googleSheetsOAuth2Api` extends the `googleOAuth2Api`. In this case, you can set parameters on the parent credentials (`googleOAuth2Api`) which will be used by all child-credentials (`googleSheetsOAuth2Api`).

That’s why I tried to overwrite credentials for `googleOAuth2Api` instead of each Google Nodes separately.

---

<div class="post-metadata">

**Author:** ![jan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jan/32/9_2.png) [@jan](https://community.n8n.io/u/jan)\
**Post date:** [October 21, 2021, 1:57am UTC](https://community.n8n.io/t/googleoauth2api-credentials-overwrites-doesnt-work/8589/4 "2021-10-21T01:57:14Z")

</div>

There was a bug. It did not work for child types when overwritten via environment variables, it only worked correctly when it got set via API. I assume we never realized that as nobody normally uses the overwrite via an environment variable. Anyway, It got now fixed and will be released with the next version.

That said do we VERY strongly discourage using an environment variable as documented because literally, every user can easily read that value inside of n8n via `$env.CREDENTIALS_OVERWRITE_DATA`. So unless that is not a problem (as you for some reason do not mind if the credentials do get leaked) set the overwrites via API.

---

<div class="post-metadata">

**Author:** ![Madriax](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/madriax/32/6946_2.png) [@Madriax](https://community.n8n.io/u/Madriax)\
**Post date:** [October 21, 2021, 8:25am UTC](https://community.n8n.io/t/googleoauth2api-credentials-overwrites-doesnt-work/8589/5 "2021-10-21T08:25:27Z")

</div>

Hello @jan

I knew it was possible to access env variable but I didn’t thought it was that easy !  
I finally managed to modify my Kubernetes Deployment to set the credentials via the API so I won’t use the environment variables anymore.

Thank you for your explanation !

---

<div class="post-metadata">

**Author:** ![jan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jan/32/9_2.png) [@jan](https://community.n8n.io/u/jan)\
**Post date:** [October 21, 2021, 12:27pm UTC](https://community.n8n.io/t/googleoauth2api-credentials-overwrites-doesnt-work/8589/6 "2021-10-21T12:27:55Z")

</div>

Glad to hear that it was helpful. Have fun!

---

<div class="post-metadata">

**Author:** ![jan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jan/32/9_2.png) [@jan](https://community.n8n.io/u/jan)\
**Post date:** [October 22, 2021, 2:10am UTC](https://community.n8n.io/t/googleoauth2api-credentials-overwrites-doesnt-work/8589/7 "2021-10-22T02:10:31Z")

</div>

fyi the above mentioned fix got released with n8n@0.145.0
