CLI to create Google OAuth 2.0 project - google-cloud-platform

Is there any command line interface to create Google OAuth 2.0 project?
To integrate the log in with Google, we need to register the project by clicking Configure A Project button and then create a new project.
https://developers.google.com/identity/sign-in/web/sign-in
Is there any CLI to automate this process?

Yes, there is: the Cloud SDK.
More specifically, you're looking for the command: gcloud projects create.
You may also want to read about creating and managing Google Cloud Projects, since you have limited quota for creating projects. You may also be interested in Google Cloud's Resource Hierarchy.
But, most importantly, you may not need a project each time you want to have a new OAuth 2.0 client. Each project can have multiple OAuth 2.0 client IDs/credentials,you just need to fill the settings and create your client credentials.

Related

Is there a way to enable OAuth 2.0 for a new Google Cloud Project via the commandline?

The process of setting up a setting up an oauth consent screen and getting the credentials.json is tedious to do every time I create project to use Google APIs. Is there a way to do this from the command line?
I wasn't able to figure out how to enable oauth with the gcloud cli by Googling.
You may follow the progress of this issue's feature request by paying attention to the issue tracker.

how to set the Storage Access API?

When I test my app using a web preview, it shows the above page.
I do not know how to install it? Set? Storage Access API
Where to install Storage Access API?
Before you can use the Cloud Shell these are steps you should follow:
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Note:
If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.
Go to project selector
Make sure that billing is enabled for your Cloud project. Learn how to check if billing is enabled on a project.
Then follow the following steps below to enable the API in your own Google Cloud project.
In the Cloud console, go to APIs & services for your project.
Go to APIs & Services
On the Library page, click Private APIs. If you don't see the API listed, that means you haven't been granted access to enable the API.
Click the API(look for Storage Access API) you want to enable. If you need help finding the API, use the search field.
On the page that displays information about the API, click Enable.
Reference:
https://cloud.google.com/shell/docs/run-gcloud-commands
https://cloud.google.com/endpoints/docs/openapi/enable-api#console
It might be already enabled but there is a bug in this page so you need to re-authenticate
Open developer tools in your browser and select Network
you will find a line starting with accounts.google.com open it and authorize cloudshell.

Creating projects on Google Cloud Platform for API Access via OAuth

Assume that there is an application, SPA, that uses Google OAuth2.0 to access the Google Drive API.
Reading the docs, the application flow seems familiar enough on the client-side specially with Google's JavaScript library for authentication. However, I have stumbled upon a roadblock during application registration phase.
When creating the credentials for our client application, I am redirected to fill out the form at the OAuth Consent Screen first. There, among other things it demands us to declare whether the application is in Testing or In Production phase, so it can decide whether the app will be available to everyone or to Test Users only.
Assume I create a project for our application and set it on testing at first and then change it to production once I am ready to publish (with a new set of credentials as well).
My question is this. What if development continues on the application for new features while one instance of the app is in production? During development and testing I would need to restrict the application to my Test Users alone. Since the OAuth consent screen is project specific, not credential specific, will I require multiple projects on the console for every environment in which the application is running?
As in,
Project MyAppTesting will permanently remain in testing mode and will denote our development/testing branch.
Project MyAppProduction is always in production and denotes my production branch.
Similarly for the mobile client:
A MyMobileAppDev project having credentials configured with the debug keystore hash
A MyMobileAppProd project having credentials configured with the production keystore hash.
(both sets of credentials share the same package name).
Is this the idiomatic way? I failed to find any documentation on the matter. Please advise.
What #JohnHanley stated is the best way and the best practice when deploying application/s in GCP.
You can create multiple projects and create different Oauth for each of the projects. Check out this link on service accounts.
In addition to that, there are also some pros and cons when it comes to billing.
Pros:
Users consider having multiple billing accounts with respective projects assigned for each account to be able to see their billing details separately. In this way you can monitor the billing for each of the respective projects for each account.
Cons:
Attaching all the projects to one billing account, however, the billing reports will show all of the sum of the cost for all the projects, but you can still use the filter menu to be able to see the charges for each project.

Is there a way we can add new projects to existing GCP monitoring workspace via a API?

I have multiple GCP projects, And I want to setup a multi-projects monitoring workspace for my environment. I would like to add all un-monitored projects to the workspace that I have already created, but via an API so that this job is automated.
Via console I know that it's possible using this link's setup (https://cloud.google.com/monitoring/workspaces/create#add-monitored-project) But how can I achieve this via an API?
Please can someone provide any inputs here.
You can manage Dashboard via API, and list services in the workspace, but API does not support adding projects to a workspace.
You can find list of all API methods here.
If you think that functionality should be supported, you can file a Feature Request.

"Unable to retrieve database locations" error when setting up Google cloud Datastore

I am trying to setup Cloud Datastore, in GCP. Upon selecting "Cloud Datastore", in console, I see the "Choose where to store your data" page, with this error:
"Unable to retrieve database locations
There was a problem retrieving the available storage locations for your data. Retry or return later to finish getting set up."
Has anybody encountered this?
I have encountered same and resolved as below. (Iam using free tier)
When you select a location in either product (Cloud Datastore or App Engine), you set the location for your entire Google Cloud Platform project. I choose location to set from App Engine.
From Home (on left side) --> App Engine --> Select a language (I have selected "python"). --> It prompts for location (I have selected "us-central") --> (press) Next
Thats it come out of the tutorial. Next time I selected Datastore, it worked fine.
Hope this helps (screens below)
SCREEN1
SCREEN2
SCREEN3
SCREEN4
I've encountered the exact same error. Some of the Google Cloud management tools are a bit buggy, gcloud included, they need more TLC and more users to report bugs to Google. The best way around the bugs is to either use the Firebase Console or the App Engine console. Either one of these two appear to be required to provide the missing management glue between the various Cloud products Google has. The Firebase console IMHO is superior to the app engine console, and that's what I would recommend using. You can create the DB from the Firebase console. it will also add Firebase to your project, giving you access to the Firebase CLI, which works very well and doesn't have all the bugs that gcloud CLI has.
Go to https://console.firebase.google.com/u/0/ to open the firebase console
Click on +Add Project and select the project you created using the Google Cloud Console.
This will prompt you to accept addind Firebase for this project. Click accept, it will enable access to the project via the Firebase emulator and firebase CLI, you definitely want this.
Under Develop in the left hand menu, select Database, from there you will be able to add the version you want. Keep in mind only the old firestore has an SLA, but the new native Cloud Datastore is better, it has the pub/sub on events on read/writes.
I use Firebase to manage microservices that are only accessible via special routing from other backends and don't use any Firebase client code, it's just so much easier to manage the functions and run them locally with the firebase emulator before deploying using the Firebase CLI. I've not had the same luck with gcloud or using the Google cloud console as opposed to the Firebase console. On the other hand, Firebase CLI, the emulator and the Firebase console are fantastic, pretty seamless experience. It's been a joy using them. I wish I could say the same about the Cloud console, I go in there only when truly necessary.