How to retrive latest stats of an existing export under hold in GSuite - google-vault-api

Iam Gsuite AdminUser having google vault privilages.
Iam trying to retrive latest stats of a particular account placed under hold.
Requested to suggest API end points for the latest stats for existing hold.
Thanks
Vyshnavi

Related

Get items count and items size of a particular account under hold in G-Suit

I am G-Suit admin user having google vault privileges. I am trying to get items count and items size of a particular account placed under hold. Could you please suggest an API endpoint to retrieve items count and items size.
You will need to create an export. Once the export is created you can get its starts without having to download it. The export that you created will generate stats about what information is holding.
Other than that your option is to actually download everything and do your own statistics.
References
matter.exports ExportStats (Google Vault API reference)
matters.exports.create (Google Vault API reference)

Google MBA Service Account get all locations

My company owns several (verified) facilities and using my company's email i can see those locations (business.google.com).
Now, my company would like to fetch the reviews in each location and present it in our company website. Before we're using the Google Place API but since it only returns the latest 5 reviews we opt to using Google My Business API to retrieve a location's complete reviews. We'd like our backend (PHP) to retrieve the reviews so using the same email I created a service account (console.developers.google.com/apis/credentials) because we don't need the end user to allow/interact anything when browsing our website.
Using postman (with my signed JWT) I have managed to get a valid access token
...that I use to retrieve the lists of accounts (mybusinessaccountmanagement.googleapis.com/v1/accounts) I could see the service account itself alone in the response.
Now, I tried calling the account locations api (mybusiness.googleapis.com/v4/accounts/{MY_ACCOUNT_ID_HERE}/locations) but it only returns and empty object response.
Can someone help me resolve this issue. Why my service account can't see the verified locations under my company's email. Is this even possible? Thank you.
Even that this is an older question - I run into the same issue calling the new Google My Business Information v1 API (getting empty results) using a service account.
It seems, that it is not recommended to use Service Accounts, I found this support article on Google: https://support.google.com/business/thread/8281160/cannot-get-access-to-gmb-locations-with-service-account-with-nodejs?hl=en
The "official" recommendation is to use OAuth.
But we finally made it using Service Account. The following steps are necessary to resolve it (at least for us it is working now):
Add a project in Google Cloud Platform
Add and enable the Account Management and Business Information API's.
Add the service account and generate a key (https://developers.google.com/identity/protocols/oauth2/service-account#creatinganaccount)
Make the Business Profile API request (you need the approval made by Google to be able to make requests against the two API's; otherwise you may run into quota exceeds as "Request per minute" is set to 0 by default). Important: It may take up to 2 weeks until, but we received the approval within about 5 days
Enable domain-wide delegation for the service account using the scope "https://www.googleapis.com/auth/business.manage". More about domain-wide-delegation: https://developers.google.com/identity/protocols/oauth2/service-account#delegatingauthority)
Add a user identity in GCP. This user also needs to be added in Google My Business for editing locations. When creating your ServiceAccountCredential object, impersonate this user.
Security concerns:
Domain-wide-delegation enables that everyone knowing/having the credentials of the service account could impersonate any person (identity) from withing GCP. At least in this case only for Business Profile API, but anyway, keep this in mind.
Also using private keys for authenticating the service account is not recommended, you should be aware to regularly change / create a new private key or there would be a solution with Identity Workload.
Hope this helps everyone facing the challenge with GMB / GCP / service accounts :-)

Google Admin Sdk is not retriving all users

I using google admin sdk to get all users from domain. Below is my code
Directory.Users.List list = directoryService.users().list();
list.setCustomer("my_customer");
list.setPageToken(nextToken);
list.setMaxResults(500);
Users users = list.execute();
I found one issue today. It is not retrieving newly created users only.
I created one new user on domain and checked immediate. Above code didn't retrieve newly created user.It retrieve all old users but not new one.
I checked on Admin sdk browser, there it shows all users with newly created also.I am sure that it was retrieving all with new users before but unable to get what is happening now ? Is there any changes need to do now
for retrieving all users with new one.?

Is it possible to find a google id from an oAuth 2.0 token stored in my database

I have a database where Google drive OAuth 2.0 tokens are stored.
There are several thousands of records and I just realized that I forgot to save the google id in the database.
Is it possible to find a google id from this kind of database record:
{"access_token":"XXXXXXXXXXX","token_type":"Bearer","expires_in":3600,"id_token":"YYYYYYYY","created":1379455302}
this is my config.:
Access Type: online
Approuval: Auto
Scopes: https://www.googleapis.com/auth/drive, https://www.googleapis.com/auth/userinfo.email, https://www.googleapis.com/auth/userinfo.profile
You should be able to get the metadata for whatever record you need based on a query of your stored data

Accessing Gmail emails through google app engine

How to get the e-mail contents by getting the user's login details in google app engine?
Try taking a look at the GMail API. You'll probably want to use OAuth.
https://developers.google.com/gmail/
This is exactly what I'm doing in my current project. Google App Engine Blog introduced a company named "Context.IO" and they provide very easy API to access GMail. I've implemented it in my project successfully.
Links
GAE Blog
Demo (You can look for a contact, and get all its emails...)
My Experience
They also provide a Explore feature that allow you to post and get json data from your gmail accounts.
However, if you registered for a free API key here, they will limit to 3 mailboxes per day. You can run a cron job to delete it daily. The nice thing is that you can contact them to get more mailboxes for development purposes :)
Hope my experience can help you
You can also use google service account. https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount
Then you can use it in order to get access to account under your domain.
$client = new Google_Client();
$client->setApplicationName('My App');
$client->setAuthConfigFile('path/to/service_account.json');
$client->useApplicationDefaultCredentials();
// account that we want to check
$client->setSubject('account#mydomain.com');
$client->setAccessType('offline');
$client->setScopes([Google_Service_Gmail::GMAIL_READONLY]);
$service = new Google_Service_Gmail($client);
$messagesResponse = $service->users_messages->listUsersMessages('me');

Resources