'Authorizing a script for a Google spreadsheet gives me error 401 deleted_client
I just made a simple script to copy and paste some data automatically for my google spreadsheet. However when I try to run my script in order to grant authorization I get the normal pop up:
But when I "Review Permissions" I get this error that I never seen before:
Usually I just get the Auth pop up for my google account. Why do you think that is? Any feedback or help would be much appreciated! Thanks!
Solution 1:[1]
The 401 Error: deleted_client. The OAuth client was deleted. error message you are receiving is due to the fact that the client from the associated Google Cloud Project was deleted.
How to check
In the Apps Script project go to Resources > Cloud Platform project.... This will open a new window with the associated project in order to check/add the deleted OAuth client.
Reference
Solution 2:[2]
The link to see your OAuth 2.0 Client ID is at:
https://console.cloud.google.com/apis/credentials?authuser=0
After that OAuth 2.0 Client ID for Apps Script is deleted, you can't add it back.
That Apps Script credential is automatically added when you associate the Google Cloud Platform (GCP) project with the Apps Script project.
As far as I know, the only thing that you can do is to make a copy of your Apps Script file, and associate the existing GCP project with the new Apps Script copy.
At least that will allow you to get the code running again with the same GCP project. You will have a problem if you'd published the original Apps Script project as a Web App. In that case you'd need publish the new Web App from the new Apps Script file, and update all the places that need to use the new url.
Unfortunately, after that OAuth 2.0 Client ID is deleted from the GCP project, your Apps Script project can't be authorized, and is therefore unusable.
If someone knows of a way to fix it, then post an answer. That OAuth 2.0 Client ID credential for your Apps Script file is automatically created, and can't be edited. And there is no way that I know of to create a new credential and designate it as being for Apps Script.
Solution 3:[3]
@Jack Chi had the right answer in the comments (reference):
- Re-associate the App Script project with another GCP Project.
- Associate the App Script with your original Project. This will create the App Script OAuth client again on your original GCP Project.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ale13 |
| Solution 2 | Alan Wells |
| Solution 3 | Jeremy Caney |



