How to find which Google Cloud Project is associated with an instance of Google Classroom? - google-oauth

I'm trying to pull our Google Classroom data into a custom web application via the Google API Client (PHP). I was able to make a successful call using a service account set up in Google Cloud, but the call returned no Classroom data.
I'm assuming the Classroom data must be associated with a different Google Cloud Project, I'm just not sure which one. I don't want to create a service account for every single project and test them, there are too many projects. I've looked everywhere and I can't seem to find the answer to the question: how do I find out WHICH project a Google Classroom integration is associated with, so I can configure the API Client accordingly?
I tried looking through all Classroom settings to see whether there was any information about the Google Cloud Project being used to store the data. I tried contacting Google Support, but so far I've had problems getting an answer to my question.
Ultimately I just want to pull the Classroom data into our web application.
Thanks

To use a service account with google classroom api you must configure Domain wide deligation. This will allow the service account to impersonate a user on your domain.
$user_to_impersonate = "admin#yourdomain.com";
$client->setSubject($user_to_impersonate);
The service account will then behalf as though they were that person. It can then see everything that user has access to.
Without delegation in place the service account doesn't have access to anything.

Related

How to integrate Google business messaging through API

Problems:
I am unable to enable Business Messages API, Because "Business Messages API" is not showing API list, While i am going to enable the API through the
https://console.cloud.google.com/apis/dashboard
I want to use auth token, while hitting the API, but the document is saying use the service.json for the credentials. i am following these doc. I am using "Google\Client()" with Laravel application.
https://developers.google.com/business-communications/business-messages/guides/how-to/agents?method=api
I am following these steps:
Login with google business account in the Dashboard
App taking multiple permissions as I have attached the permissions list and taking the auth token.
Open the chat box for the Business.
So please guide me, where i am going wrong. What is correct way to implement this.
Requirement:
I want to create a custom chat box for google businesses, Where business owner will login into the web app and He can easily manage the multiple business chats in one dashboard.
As per your given information, you have to be a partner of Google. As per google documentation, you need to be a partner of google and then you can create the agent and can send and receive messages. You can integrate the business messages API by following this documentation:
https://developers.google.com/business-communications/business-messages/guides
In this process, you need to be a partner of Google. The complete process is given on the link. If you follow this link, then you can use their built-in libraries easily and can send messages easily.
So far the permission for API, it might not be found for you because you might have to take permission for the particular project that is registered on google and then you will see the business messages API and you can enable it and use it. The reason as per the basic step:
https://developers.google.com/my-business/content/basic-setup
Sometimes, you have to submit the request form to take the API access for particular APIs. Or Share how are you using that API.
If you do not find a form for business messages API then you can ask for the information from bm-support#google.com. they mostly respond on a working day.

Is it possible to pull reviews using a Service Account for a Google My Business Account?

Really straightforward question. Is there a way to use the Service Account credentials to gain access to a particular Google My Business location Reviews?
(Some context, I'm not pulling from an unowned business. I have access to the information and we're an authorized user. Essentially we are the business owners or agency)
https://developers.google.com/my-business/
For broader context, we came across this issue:
How do I authorise an app (web or installed) without user intervention?
... and we want to automate the acquisition of reviews for a client who wants to have access to their reviews. However, we need to manually get the refresh token...
Steps 11 and 12 are as such...
Click Step 2 and "Exchange authorization code for tokens"
Copy the returned Refresh token and paste it into your app, source code or in to some form of storage from where your app can retrieve it.
We would ideally like to automate this side of the process. Is this feasible using the Service Account and a Restful Endpoint or a library provided by the Nuget Package?

Another account access my Analytics API

I want to build a dashboard to my clients access your respective website analytics. But, after some research, I'm stuck.
Let's imagine the scenario:
My Analytics Account:
Client X - websitex.com
Client Y - websitey.com
In my dashboard, when the cliente Y log in, the data (pageviews) of websitey.com is shown on graphics.
But, there's a way to do that? By the moment, the only thing i got is retrieve information for my logged account (my analytics ID), not the information about another account.
There's a way to use the Google API, or, I'll have a "separate database" to save data each website?
Sorry, I'm really lost at the moment.
You can only view Google Analytics Accounts that you are authorized to view. For some reason this is a source of major confusion (seeing that your are not the first to ask), although it should be fairly self-evident.
If you want to see data from your clients account you have to ask your client to add your Google email to the GA account. If an email address is added to multiple accounts you can, via the API, choose between the accounts. Clientside authorization (OAuth2) will only work as long as somebody is logged in via a client application (usually a browser). The practial effect is that everybody who is authenticated via OAuth against Google will see only his own GA accounts, not other peoples data.
If you want a serverside application to pull data from various GA accounts you need a service account. But even the service account needs to be added to the GA accounts.
You can use the core reporting API, but the API will not give you access to accounts that you are not authorized to look at; your client needs to authorize you (or your applications service account).

How do I get Google Analytics data into a CMS without asking the user to authenticate?

I have a web application backend for my clients web site. Authorised staff can log in to the backend and view data.
I want to pull some data from Google Analytics to be viewed in the backend, but GA seems to insist that the user is logged in to their Google account themselves using OAuth2
I want to be able to authenticate the server not the user. They already have permission and it seems unnecessary and possibly intrusive to ask them to link their Google accounts to the GA account and possibly even have to create one first.
The server already has to supply a client id, client secret and an api key, so it's not as if there isn't already an authenticated connection.
I'm guessing that there must be a way to pass the Google Analytics account credentials to OAuth2 somehow but I am not that familiar with OAuth2
Is this possible and how would it be done. A simple example or a nudge in the right direction would be appreciated
There are similar questions around but the ones I have found do not answer my question in the way I need.
Yes you need to store the authentication, but you may be able to use Google Analytics Super Proxy for your needs. At the very least you can see its code on how it stores the authentication.
You authenticate once, input the data you need scheduled from the GA Reporting API, then take the data feed and use it to build charts in your intranet. Any user can view those charts without needing to login to GA themselves.

Google Tasks API authorization

I can see many related questions on SO, but none that answers exactly what I'm confused with.
I'm using Google Calendar API in a .NET desktop application that allows user to provide his/her username/password, logs in on his behalf and adds some events to the calendar. Now I want to do exactly the same thing for Tasks feature. I'm trying to use Google Tasks API for this, but have been told that I need to do some OAuth kind of authentication, and even before that, I need to go to my gmail account and set permissions and get my project "key" to enable it.
Now does every user of my application need to do these steps in their Gmail account? Or do I need to do this in MY gmail account once and then my application code will be able to use the generated project "key" to enable my users to add tasks to THEIR gmail tasks list?
Figured it out. For anyone having a hard time understanding this, here it is:
The "key" generation step needs to be done only once per application, not for each user who's going to use your application. To generate a key, login to your Google Account and go to Google APIs Console page. Click API Access button and that's where you can generate keys for different kinds of applications like browser apps, desktop apps, Android apps etc. After registration, you'll need to take Client ID, Client secret and API key from this page and put them into the code. Sample code (.NET) for task creation and several other Google features is available here.
Once your user runs your application, he'll be taken to his Google account in his default browser where he'll be asked if he wants to allow this application to write to his calendar/tasks list. This page will display your logo and description text too that you can provide at registration time. Once allowed, this step won't be required again in the next one hour (this may be adjustable, i don't know yet).