can we open a command prompt from google appscript - google-apps-script

I want to run a command prompt and give message to user on specific conditions.
Conditions/ logic is written in google appscript as we are using Gsuite files, is it possible to open my local command prompt and run a command like we do from powershell or vba.

No, in the way you are defining it that feature is not supported in Apps Script.
However, you might have heard of clasp which is a command line interface to develop and manage Apps Script projects from your terminal rather than form the Apps Script editor.
You will be able to manage versions of your projects, run, deploy and create scripts and so on. In this guide you can see an overview of all you can do with clasp. This is the clasp Github repository in case you are interested in taking a further look.

Related

How to run gcloud if Google Cloud SDK if my project is on another drive?

I'm building an API with Google Cloud functions and I had the same issue as the guy from this post: Could not load the default credentials? (Node.js Google Compute Engine tutorial)
When trying to use my API, I received this error:
Could not load the default credentials. Browse to https://developers.google.com/accounts/docs/application-default-credentials for more information.
So I went on and followed the steps suggested in the question I mentioned. I downloaded the gcloud SDK, installed it, and at the end of the installation wizard there is an option to run the google cloud cli immediately.
I ran it successfully and logged in properly, now any time I open the command prompt I can use the gcloud command without a problem.
Mi issue is the following. I'm running my commands in VSCode bash terminal and I get an error saying that the gcloud command is not found.
My project is in my D: drive, and the SDK is on C:, which I believe is the reason why the gcloud command is not recognized when I attempt to use it.
Should/can I install the Google Cloud SDK in my D: drive and use it there, or should I move my project to the C: drive?
I read somewhere that this might be a problem with the bash terminal, but I tried running it from command prompt in VSCode and I get the same error, so I guess it's got nothing to do with it.
Thank you for your time.

How to give users access to app script managed by a GCP Project

I have an app script linked to a spreadsheet that has a few functions to automate some processes for users. I recently updated the project to be linked to a standard GCP project I created so I could create OAuth credentials for an unrelated process in this script. However, now when users go to run the functions, they get a 403. Is there a place in the GCP console where I can give them access? I am not using any OAuth credentials for these functions. Just the standard app script interactions with the Google Sheet.
I think when you move to GCP you are required to use OAuth and they have to enter their credentials again. Found in the docs.
You have to configure the OAuth Consent Screen as is explained in the official docs about link a Google Apps Script project to a standard Google Cloud Project --> https://developers.google.com/apps-script/guides/cloud-platform-projects

Can't run scripts anymore due to Error 401: deleted_client The OAuth client was deleted

I linked my google apps script project to a project on GCP. Then I deleted the GCP because I didn't need it. Now, I can't run scripts inside my google apps script project.
First, I got this popup. Then, after clicking the first button I get to error message in my subject line.
Originally, I linked from google apps script to GCP from the Resources/Google Cloud Project option. There is no option to unlink...
How can unlink my Google Apps Script from my now-deleted GCP.
As written in the documentation,
You can't switch a script project to use a default GCP project. Default GCP projects are deleted once the script project they were created for is set to use a standard GCP project.
You cannot unlink as the default project is deleted. You have to create a new GCP project and link to the new project, which will automatically unlink from it's old project.

Google apps script GCP projects are not deleted from console when apps script files or container files are trashed from Drive

I noticed that the GCP projects created by default when creating a new script are not deleted from the GCP Console when the app script files are placed in the Drive recycle bin.
Have you ever encountered this problem?
As I develop many scripts, I reach the quota limit ...
On the other hand, I wanted to do a manual cleanup but I cannot find the gcp project ID in the applications script file. Do you know a solution?
After looking at some documentation I found the following solution:
Copy the App Script folder id on Google cloud resource manager
Open the Cloud Shell using the top right terminal icon.
Then list all the project under your App Script folder
gcloud projects list --filter='parent.id=APPS_SCRIPT_FOLDER_ID'
Then delete all projects one by one
gcloud projects delete PROJECT_ID
Now you can delete the App Script folder in Google cloud resource manager.
Be sure you have the Organization Administrator, Folder Admin, and Project Deleter roles under IAM > permissions of the main project.
According to the official documentation:
When a new Apps Script project is created, a default GCP project is
also created behind the scenes. This GCP project is hidden, meaning
most users aren't able to directly locate, view, or update the project
in the Google Cloud Platform Console. However, admins and domain users
that have the resourcemanager.projects.list permission on the
parenting GCP folder are able to view and configure default projects.
My interpretation on this is that you can't locate, view or update the GCP project unless you have resourcemanager.projects.list permission on the parenting GCP folder are able to view and configure default projects.
The solution would be to contact the administrator to further help you on this issue.
Here you may find the list of GCP projects that you have access to modify, delete or view:
https://console.cloud.google.com/cloud-resource-manager
Since you don't have access to the organization directory which contains your GCP projects, you might be seeing this message:
Related article:
Google Cloud Console Quotas You don't have permissions to perform the action on the selected resource
2 strange things happen on my hand :
1 - As administrator of my organization, i can see into the gcp admin console the ressources folder managed by Apps script named "system-gsuite\apps-script". Or regarding the official Apps script Guide i should not :
2 - This folder contains many apps-script projects, even apps script files that have been already deleted ?! But the official documentation noticed that they should be removed but htis is not my case ...

Access attached code for installed Google Add-on

Basically the question is: Can a user access the installed Add-on's code in any way like e.g we can access through Tools Menu -> Script Editor(on SpreadSheets) while on development & pushed through clasp CLI?
Negative. Users who have installed the Add-On do not get to see the Add-On code. If they open a Apps Script editor instance from an editor in which an installed add-on is running, the user will get a blank Apps Script project template to work on, not the Add-On code.
They will however see the names of the functions executed in their Apps Script dashboard.