GCP project created by an app authorized by me, but I do not have access to it? - google-apps-script

I'm developing some automation/integration between a CRM software and my google account. I am attempting to use the Google Apps Script API so I can remotely execute functions in Google Apps Script through the integration I'm building from within the CRM software.
The only problem is, when attempting to run a function which calls a GAS function through the API, I get the following error:
"Apps Script API has not been used in project project number before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/script.googleapis.com/overview?project=103424032563 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry."
This would normally be no problem, as I would simply access the GCP portal through the link and enable the GAS API, but when I try to access my project, I don't have access at all, and get the "failed to load data" error.
Further complicating my issue, GCP support will not help because they suspect I am a hacker trying to obtain access to a project that, for all they know, isn't mine.
And because I cannot access this project to authorize the API, I also cannot associate my google script with the same project, as this is a requirement for the Google Apps Script API to function.
I suspect it's the CRM software piece in which I'm developing this integration that is causing this error, (somehow the GCP project is being created by a different user,) but they haven't been all that helpful in determining what's going on.
Have any of you had a similar situation? And, if so, how did you approach solving it?

Further complicating my issue, GCP support will not help because they
suspect I am a hacker trying to obtain access to a project that, for
all they know, isn't mine.
Google Support does not refuse to help. They don't accuse you of being a hacker. Google Support can look at the project and see if you have credentials in the project and if you do they can explain how to authorize yourself. However, Google Support requires a support agreement, which is not free. If you do not have one, then you are not entitled to technical support only billing support. Look up your billing account ID and send a request for billing support. Your billing account will also show you which projects are linked to your billing account.
The issue is that you are trying to access the wrong Project ID. Figure out what is the correct Project ID. If you have the Cloud SDK installed execute this command gcloud projects list and this will tell you which projects your credentials have access to.

Related

Testing Google Apps Script using Google Cloud APIs

I am working on implementing a Google App Script project which makes use of various cloud APIs like Big Query, Cloud SQL, Google Ads etc. Implementation works pretty well through a project where GCP project ID is configured.
But I would like to have a development only version which I can use for my validation.
If I use a test deployment as mentioned on https://developers.google.com/apps-script/add-ons/how-tos/testing-editor-addons, it works. But this works only via the script project where GCP project is configured. For other, it gives "Google developers console API activation" error.
So question here is - is it mandatory to provide the GCP project ID even for test deployments? Is there any configuration that I can use for getting around this problem?
Please note - I can always create a test deployment from the production version of App Script project (where GCP project id is added). But I would like to maintain 2 versions possibly without having to add GCP project in development version.
Kindly advice.
It depends on how you or your team have designed the solution. Also it's depends on if the solution is requiring users to authorize all the scopes, if it's using a service account, among other factors.
One design might be based on the use of a single Google Cloud Platform standard project to handle all the OAuth authorizations.
Another design might be based on using two or more Google Cloud Platform projects. I.E. you could use a default project for Google Apps Script and a standard project another for the Google APIs like BigQuery. This setup might require the use of a service account.
Related
Create a development environment and use a deployment tool for Google apps script in spreadsheets
Best development setup for developing gmail add-ons locally?

Google work space add on with Google apps script, How can I deploy it all staffs of mine

I'm a corporate systems administrator.
our company uses google-workspace, and I need to extend gmail by using google-apps-script.
Since I created a google-workspace-add-on with google-apps-script.
Coding and testing was not so hard by following this page.
https://developers.google.com/gsuite/add-ons/how-tos/testing-gsuite-addons
However, deploying is pretty confusing for me.
this add-on is only used for our company, and it includes api-key for our private service.
Then I want to avoid the add on to publicly published.
The following instruction explains to use GCP project, and then install it from administrator console.
https://developers.google.com/gsuite/add-ons/how-tos/publish-add-on-overview
I want to know
1, Is there any way to deploy my google-workspace-add-on more primitively ?
2, If I followed this instruction, is it for free or costly?(I have no knowledge of GCP billing system)

Can't switch google cloud project on GAS Editor

I am not able to switch google cloud platform project in GAS editor.
What I am doing is…
Open the google sheet GAS editor
Open Resource --> Cloud Platform Project
Enter project number that I want to connect
With the process above, I was able to switch a cloud platform project but now it returns an error
‘Project does not exist, or you need edit access to it.’
I am using the same cloud project and same account(editor) that I used before and properly worked. I tried do the same with a owner account, but it didn’t work, either.
Also, this cloud project is not a default project nor a hidden project. (If it does, I guess it should not be able to access through GAS editor from the beginning)
I have checked documentation below, but it tells me only case when switching to a hidden project.
https://developers.google.com/apps-script/guides/cloud-platform-projects
Does anyone have a solution or suggestion??
Thank you for the help in advance.
Problem Solved.
I figured out that OAuth IDs which are generated when make connection docs to the cloud project are not be deleted even though delete actual document files.
What I have done is...
Login Google Cloud Platform
Go to APIs&Services --> Credentials
On OAuth 2.0 client IDs, delete unnecessary contents from the list
Back to your docs and switch the cloud project.

Pulling Google Apps user creation date

What options are there to pull a GApps user creation date?
I saw that the Admin SDK is capable of it, is it the only API capable of doing this? does any of the previous one also capable of?
If possible using GAS, it will be most excellent,
Thank you!
Indeed there does not seem be Google Apps Script services to pull the creation date. The DomainUser class provide interesting functionality for interacting with domain users (only for admins).
Using the Admin SDK with Google Apps Script using UrlFetchApp.addOAuthService is not as complex as it looks. You can read this answer which will throw some light on how you can use external API calls for certain Google API and bring the data to Google Apps Script.
The scope for the ADMIN SDK will be as follows
oAuthConfig1.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken
?scope=https://www.googleapis.com/auth/admin.directory.user.readonly");
Notice that in this case I have requested a readonly scope.

Accessing the Administrator Audit Log via Google Script

Despite fervent searches, I don't believe I have come up with quite the results I am needing. Within the Google Apps for Business Administrator console, under "Reports" there is the "Audit Log." This audit log nearly displays everything I need; however, I am needing the actual name of the file instead of the fileID provided in the report.
The ultimate endgame is to generate, via Google Script, an automated daily report that gives this same data to a few users daily. Is there any means by which I may access this data? I have been pouring over the APIs, and perhaps I've missed something, but I don't feel that I've found what I needed.
Any thoughts and help would be greatly appreciated. Thank you for your time and considerations.
This is possible using the Google Apps Admin Audit API. This uses OAuth and that is a bit tricky to setup sometimes. You can see the set up process in this video that we did. Except as the example shows, instead of the YouTube APIs enable the Apps Reporting and Audit APIs in the API Console.
I built out a simple example of this that you can see in operation. Access this URL after having been logged in as the domain admin. It will automatically create a Spreadsheet in your Drive with the latest Audit logs exported. This is a web app that is deployed as "Run as user".
I've open sourced this Github here. You should substitute in the right OAuth2 Client ID/Secret. The code is pretty rough so you'll want to clean it up. I am selectively logging a few columns but if you look at the API docs, there are other things you can log as well.
Once the OAuth token is set up you can have this run on a trigger as well as long as you refresh the token.
Hope this helps.