Enable Google My Business API. Api calls failed - google-api

I tried to access GMB account list api with an access token having scope
https://www.googleapis.com/auth/business.manage
{
"error": {
"code": 403,
"message": "Google My Business API has not been used in project xxxxxx before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/mybusiness.googleapis.com/overview?project=xxxxxx then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
"status": "PERMISSION_DENIED",
"details": [
{
"#type": "type.googleapis.com/google.rpc.Help",
"links": [
{
"description": "Google developers console API activation",
"url": "https://console.developers.google.com/apis/api/mybusiness.googleapis.com/overview?project=xxxxx"
}
]
}
]
}
}
Whenever I tried to submit request from I got an email from GMB that
Your company already has a whitelisted project to access the Google My Business API. At this time, we are only whitelisting one project per business..
I checked, but there is no library with name Google My Business.
Current enabled Libraries are

Have you submitted the form to get access to the GMB API?
https://docs.google.com/forms/d/e/1FAIpQLSfC_FKSWzbSae_5rOpgwFeIUzXUF1JCQnlsZM_gC1I2UHjA3w/viewform
When you fill it, you have to precise the email addresses that Google will grant access to. Maybe someone else filled in for your company but didn't mention your email address.
In my case, when I received a confirmation email from the GMB team, I was able to see the GMB API when I searched for it in the console (see screenshot)
Then, all I had to do was to click to enable it.

Related

I want to read my server gmail account email from java application

I need help in understanding the exact path I should follow to solve my problem.
I hava a gmail address(I can say this gmail is used by my java application) Whenever a mail comes to this gmail address. I want my application to know and get the email from my gmail inbox and proceed with the further logic.
So far Going through the google docs I have created a topic and a subscribe which has subscribed to that topic. Using push mechanism I'm also able to call my endpoint whenever a message get published manually from google console to that topic.
Now I want if any email comes to my gmail address, it should notify my endpoint and after I can just fetch the email from the gmail and proceed with the logic.
Here As I have only mine gmail address which I will be accessing I don't think I need to go for Oauth2 mechanism for gmail authentication purpose.
I went through the documentation which says. I should create a watch request, then maybe if any gmail inbox receives a mail it will notify my endpoint and then I can fetch the mail and proceed further. But I'm not sure what and how exactly I should proceed Do I need a service account if yes I have already created a service account and downloaded my private key.
GoogleCredential.fromStream(new FileInputStream("file.json"))
.createScoped(Collections.singleton(GmailScopes.MAIL_GOOGLE_COM)).createDelegated("xxxxx.iam.gserviceaccount.com");
then I'm calling watch request as :
Gmail gm = new Gmail.Builder(GoogleNetHttpTransport.newTrustedTransport(), JSON_FACTORY, googleCredBuilder()).build();
WatchResponse res = gm.users().watch("me", request).execute();
I got this error.
POST https://www.googleapis.com/gmail/v1/users/me/watch
{
"code": 400,
"errors": [
{
"domain": "global",
"message": "Precondition check failed.",
"reason": "failedPrecondition"
}
],
"message": "Precondition check failed.",
"status": "FAILED_PRECONDITION"
}
Can someone please help how exactly I should proceed to achieve my goal.
Thank you.
"Precondition check failed.",
Means that you are trying to use a service account with a standard google gmail address.
Service account authorization only works with gmail api and google workspace accounts once domain wide delegation has been configured.
You have two options
swtich to using a google workspace domain account.
Use Oauth2, set your application to production and not test so that the refresh token wont expire. Authorize your application once store the refresh token, then upload it to the server. It will be able to use the refresh token to request a new access token whenever it needs.

How do I list google google business profile locations from an account ID using google business profile API without getting a 429?

I have been approved for the google business profile api after folliwing the prerequisites and gaining approval for access found here. Continuing, per the instructions in the project in the google business cloud dashboard I have added the following API's:
Google My Business API PRIVATE
My Business Account Management API
My Business Business Calls API
My Business Business Information API
My Business Lodging API
My Business Notifications API
My Business Place Actions API
My Business Q&A API
My Business Verifications API
Continuing per the instructions found here for basic set up, I am able to get to the point when I can get the Account ID of the person authorized in the Google api playground.
With the exception of search functionality, when trying to do anything related to the scope of businessbusinessinformation.googleapis.com all my requests return a 429. For example, the following request:
https://mybusinessbusinessinformation.googleapis.com/v1/accounts/1023160XXXXX/locations
{
"error": {
"status": "RESOURCE_EXHAUSTED",
"message": "Quota exceeded for quota metric 'Requests' and limit 'Requests per minute' of service 'mybusinessbusinessinformation.googleapis.com' for consumer 'project_number:40740XXXXXX'.",
"code": 429,
"details": [
{
"reason": "RATE_LIMIT_EXCEEDED",
"#type": "type.googleapis.com/google.rpc.ErrorInfo",
"domain": "googleapis.com",
"metadata": {
"service": "mybusinessbusinessinformation.googleapis.com",
"quota_limit": "DefaultRequestsPerMinutePerProject",
"quota_location": "global",
"quota_metric": "mybusinessbusinessinformation.googleapis.com/default_requests",
"quota_limit_value": "0",
"consumer": "projects/40740XXXXXXX"
}
},
{
"#type": "type.googleapis.com/google.rpc.Help",
"links": [
{
"url": "https://cloud.google.com/docs/quota#requesting_higher_quota",
"description": "Request a higher quota limit."
}
]
}
]
}
}
Reviewing all the visible quotas related to the API I can't find any that say 0. I have filled out a general form for quoata increase as I can see nowhere in the dashboard where I can directly see the DefaultRequestsPerMinutePerProject setting to request a quota increase.
Since originally writing this a few days ago, I made a quota request increase via the google form, but I am not sure if that will address anything as it seems strange this would not be working "out of the box" after receiving approval prior for this api.
Any suggestions would be great!
After contacting google api support, the 429 went away, there is nothing else that was done to resolve this issue.
I am unsure if it was related to my account specifically or if it was related to the normal expected process for using this endpoint on all accounts.

Error Migrating Google Workspace to O365 - Calendar API Errors

I'm trying to build out a migration from Google Workspace into MS365. I've tried each of MS's recommended methods; Automatic, Manual, and PowerShell. For each one, I get the same error message
post-migration
uri=https://www.googleapis.com/calendar/v3/users/me/calendarList?maxResults=250 response={ "error": { "code": 403, "message": "Google Calendar API has not been used in project 206754733531 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/calendar-json.googleapis.com/overview?project=206754733531 then retry.
If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
"errors": [ { "message": "Google Calendar API has not been used in project 206754733531 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/calendar-json.googleapis.com/overview?project=206754733531 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.", "domain": "usageLimits", "reason": "accessNotConfigured", "extendedHelp": "https://console.developers.google.com" } ], "status": "PERMISSION_DENIED", "details": [ { "#type": "type.googleapis.com/google.rpc.Help", "links": [ { "description": "Google developers console API activation", "url": "https://console.developers.google.com/apis/api/calendar-json.googleapis.com/overview?project=206754733531" } ] }, { "#type": "type.googleapis.com/google.rpc.ErrorInfo", "reason": "SERVICE_DISABLED", "domain": "googleapis.com", "metadata": { "consumer": "projects/206754733531", "service": "calendar-json.googleapis.com" } } ] } } . --> The remote server returned an error: (403) Forbidden.
When I follow the link
https://console.developers.google.com/apis/api/calendar-json.googleapis.com/overview?project=206754733531**
I see the following screen
Relating to the PERMISSION_DENIED portion of the error, I have ensured that the ServiceAccount associated with the project has been added to the project and has the requisite permissions based on MS's documentation.
I really don't know what I'm doing incorrectly or where I'm going wrong. I'm incredibly new to all things programming and development so I apologize if this isn't nearly enough detail. I'm happy to provide more context/info as needed.
Google Calendar API has not been used in project 206754733531 before or it is disabled
Means that the Google calendar api has not been enabled in your app or its disabled.
Here are a few things to check in order of likelihood of causing your issue.
I would double check that you are in fact checking the correct project on google developer console for the service account credentials you are using. You may have downloaded a file for a different project and are checking the wrong one.
After that i would check the quota allotment you have for the google calendar api. Click the manage button in that link. If your quota is 0 then google has disabled your access for some reason. If they have check your email they should have told you why it was disabled.
SERVICE_DISABLED
If you have created the service account on google developer console logged in as a standard gmail user its not going to work. Service accounts only work with google calendar api with google workspace.
PERMISSION_DENIED
Make sure that you are creating this service account on the domain that you intended to access. Google calendar only works with service accounts from google workspace domain accounts with domain wide delegation setup. Great guide in setting up delegation Perform Google Workspace Domain-Wide Delegation of Authority just change the scopes to the google calendar scope you are using.

Google Calendar API request is denied for scope https://www.googleapis.com/auth/calendar.app.created

My app needs to create a Google Calendar and manage events in it for users. Google API Console allows to create a consent form for this scope:
https://www.googleapis.com/auth/calendar.app.created
It is supposed to allow creation of secondary calendars and events in those calendars. Description reads:
Make secondary Google calendars, and see, create, change, and delete
events on them
However, after a user gives permission through the consent form etc, I am getting PERMISSION_DENIED when I try to create a calendar (I am using the REST api https://www.googleapis.com/calendar/v3/calendars)
{
"error": {
"code": 403,
"message": "Request had insufficient authentication scopes.",
"errors": [
{
"message": "Insufficient Permission",
"domain": "global",
"reason": "insufficientPermissions"
}
],
"status": "PERMISSION_DENIED"
}
}
My code and the rest of the plumbing (authorization code, access token etc) works because if I use this scope:
https://www.googleapis.com/auth/calendar
I am able to create the calendar.
So, anybody knows if https://www.googleapis.com/auth/calendar.app.created is deprecated or something? It is not listed in the V3 calendar documentation but I was hopping that it continue to work. I hate to ask the user for full permission to all calendars since I only want to create and access a secondary calendar and that scope supposed to do exactly what I need.
Thoughts?
As you can see under OAuth 2.0 Scopes for Google APIs, https://www.googleapis.com/auth/calendar.app.created is not a valid scope for Calendar API v3.
The documentation for Calendars:insert states that the only valid scope for creating a new calendar is https://www.googleapis.com/auth/calendar
You notice yourself that if you try to create a calendar with https://www.googleapis.com/auth/calendar.app.created - be it on OAuth2 playground or elsewhere - the request fails with a 403 error
CONCLUSION
Unfortunately https://www.googleapis.com/auth/calendar.app.created is not a valid scope, the acceptance of this scope on OAuth2 playground is a bug.
https://www.googleapis.com/auth/calendar.app.created might not seem as valid scope - but works for me.
Successfully could create new calendar with that scope, then manage events within it, and calendar itself appears on list of calendars in calendar.google.com
Can't really help much without knowing exactly the flow you have on creating and executing requests to google. Also keep in mind it worked for me with server side app. Using latest library provided by google for PHP.

How can I get the user's first and last name by his gmail?

I am developing an application to work admin.google.com. In my application through Google_Service_Directory I got a users. But I can not understand who it is - I see only gmail. I want by gmail to get the name and surname. How can I do it?
On the Internet, I found answers to the Google Plus library. But Google Plus is closing. What are some other ways to get your first and last name by gmail?
You have a few options and they will give you similar information.
people get Google+ api.
Request:
GET https://www.googleapis.com/plus/v1/people/me
response: people.resource
"objectType": "person",
"id": "11720047553265346",
"displayName": "Linda Lawton",
"name": {
"familyName": "Lawton",
"givenName": "Linda"
Note: this call appears on the Google+ api documentation how ever this end point is not being shutdown. (waiting for feed back from google on if this is shut down or not.)
Userinfo endpoint
The second option is to call the identity server directly to the userinfo endpoint as described in OpenIDConnect requires profile scope i think
people.get people api
people.get from the people api
request
GET https://people.googleapis.com/v1/people/me?personfield=names
response
"displayName": "Linda Lawton",
"familyName": "Lawton",
"givenName": "Linda",
"displayNameLastFirst": "Lawton, Linda"
Cant search on email
Note: This will give you the information on the current logged in user. There is no way to get back the name of a persona directly by their email address. Assuming you are running an service account with domain wide delegation you may be able to use people.get with the user id of one of the users on the domain. I have not tried this

Resources