Error when read reviews from Google My Business REST API - google-my-business-api

FIrst I get the access token, then I run command in Postman/Insomnia. Below is the cURL version:
curl --request GET \
--url https://mybusiness.googleapis.com/v4/accounts/103754858715037057901/locations/ChIJfSoYcTGuEmsR1Vs1rPs6WRw/reviews \
--header 'Authorization: Bearer ya29.a0AfH6SMCfj3Ekjj8qwudOSYqIj8cEcHvtpyLyQ1SRFvQc62ItV7ph2PJeFLqIzuh41IxDKmel348DerYSQx-AaxcNw_7iYmWcSZUfl85uiZK_SOMEACCESSTOKEN_GpBAFXeVbGWeCPjyk1BjF8spjmQzNO' \
--header 'Content-Type: application/json' \
--header 'X-GOOG-API-FORMAT-VERSION: 2'
But I get error like below:
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.mybusiness.v4.ValidationError",
"errorDetails": [
{
"code": 3,
"message": "Resource could not be found"
}
]
}
]
}
}
What did I missed here?
The account already enable the API and billing.

In my case, the problem was incorrect Location ID. I was under impression that Place ID is same with Location ID, it's not. Place ID is alpha-numeric, and Location ID is numeric-only
To get location ID, you need to:
Get Profile ID, then
Get list of Location IDs that belong to that Profile ID
After getting the correct Location ID, I get can the reviews

Permana is correct that you need the Profile ID and not the Place ID. I would like to add to Permana's answer to make it easier for others to find the Profile ID. The Profile ID can be found by logging into the Business Profile Manager -> Businesses (left-hand side at the bottom) and then clicking on the "See your profile" button. Doing so will open up Google search. Click on the three dots next to "Your business on Google" -> Business Profile Settings -> Advanced Settings.

Related

Why am I getting authorization code is not in a recognised format?

Hello everyone I need help please. This is about Seatgeek Oauth request.
In Postman, entered the required fields to get access token.However I am getting this error below.
{
"status": 400,
"message": "Oauth code invalid",
"errors": [
{
"message": "Oauth code invalid",
"short_message": "Code invalid",
"verbose_message": "The authorization code provided was not in a recognized format.",
"hint_message": "Switch code verifier",
"category": null,
"parameter": null,
"code": 40322
}
],
"meta": {
"status": 400
}
}
Now let me add the endpoints I used
Base endpoint: https://api.seatgeek.com/2/oauth/access_token
Params: client_id = xxxxxxxxx
Params: scope = offline_access,read-user-first-name,read-user-email,read-user-phone,view-soundersfc-crm-id
Params:grant_type = authorization_code
Body:x-www-form-urlencoded:
client_secret = xxxxxxxxxxx
code = “ ”
The full url will be something like this : https://api.seatgeek.com/2/oauth/access_token?client_id=xxxxxxxxx&scope=offline_access,read-user-first-name,read-user-email,read-user-phone,view-soundersfc-crm-id&grant_type=authorization_code
Please help me identify this code error. Any help will be highly appreciated
here is the Seatgeek Oauth documentation.
https://partners.seatgeek.com/enterprise-client-integration/oauth
SeatGeek API OAuth documentation not accuracy. you need a little change a scope.
(just use offline_access)
#1 Using this URL from Browser
https://seatgeek.com/oauth2?scope=offline_access&client_id=MzA...zcy
#2 You can get the code in URL address of browser
It will return your registered redirect URL and code
Copy that code and call POST to get token by curl
#3 Get token
curl -X "POST" "https://api.seatgeek.com/2/oauth/access_token" \
-H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \
--data-urlencode "code={received_code_from_#2}" \
--data-urlencode "client_id={your_client_id}" \
--data-urlencode "client_secret={your_client_secret}" \
--data-urlencode "grant_type=authorization_code"
Note #1
you can get the client id /secret from developer portal
Note #2
code is JWT format. The payload is this content.
I decoded from jwt.io

Create subscription for OneDrive Business returns 403 forbidden

I'm using Microsoft Graph API to build and integration with OneDrive. Everything has worked well and I have been able to register my App, get a token, navigate the OneDrive items and download files.
I started creating subscriptions to receive notifications from OneDrive when user does something. This works without any problem when user signs in with their "personal account" but when they use "work or school" account I get the following error message:
{
"error": {
"code": "ExtensionError",
"message": "Operation: Create; Exception: [Status Code: Forbidden; Reason: The caller does not have permission to perform the action.]",
"innerError": {
"request-id": "ffaf7fae-e0b0-4cd8-b911-bac4c2fb290a",
"date": "2019-09-18T00:18:40"
}
}
}
And this is the call I make to create the subscription:
curl -X POST \
https://graph.microsoft.com/v1.0/subscriptions \
-H 'Authorization: Bearer [access_token]' \
-H 'Content-Type: application/json' \
-H 'Host: graph.microsoft.com' \
-d ' {
"resource": "me/drive/root",
"changeType": "updated",
"clientState": "[email_Address]",
"notificationUrl": "https://webhook_url",
"expirationDateTime": "2019-09-19T04:43:47.6099364+00:00"
}'
The user has Files.ReadWrite.All permission which based on the documentation should be enough.
I had this same problem. The only difference is I am trying to setup a driveItem subscription on a business OneDrive path /users/<id>/drive/root but getting the same error as you on the response.
So, using the same access token, I did a GET /v1.0/users/<id>/drive/root and fetched the driveId of the parent from the response. Then I attempted to create the subscription at /drives/<driveId>/root and it worked. All requests were using the same access token and the previous way used to work for months.
So you might try doing a GET for your /me/drive/root and see if you can set it up with the driveId.
As a bonus, the subscription is now sending web-hooks like I expect.

Monitoring connectivity for Slack and PagerDuty

We are using PRTG to monitor a number of internal resources, and we have set it up to alert us on a Slack channel and/or via PagerDuty (depending on severity) using their respective APIs. Considering that Slack and PagerDuty are external to us, we would also like to monitor whether our PRTG instance can access them -- basically, a form of self-monitoring or Who Watches the Watchmen?
So far the only reliable method we've found for Slack is to post an actual message to a private "testing" Slack channel, e.g. (Slack URL details redacted):
POST https://hooks.slack.com/services/XXX/YYY/ZZZ
Content-Type: application/json
{ "text": " ", "channel": "#prtg-webhook-test" }
Similarly, PagerDuty's Events API appears to be POST only, and the valid actions are limited to trigger, acknowledge, and resolve:
POST https://events.pagerduty.com/v2/enqueue
Content-Type: application/json
Is there a good way to test HTTPS connectivity without posting an actual Slack message / creating an actual PagerDuty alert? I couldn't find anything in documentation for either service, or a creative way to create an appropriate sensor in PRTG.
For Slack you might rather want to make an call to the API, not to a webhook.
I would recommend using auth.test, since its one of the few methods that has no rate limit.
Also, for the whole Slack service you can see the current status on this official webpage.
For pure connectivity, you can do a POST against the Events API with an empty payload, and you'll get an error message back:
curl --location --request POST 'https://events.pd-staging.com/v2/enqueue' \
--header 'Content-Type: application/json' \
--data-raw '{}'
{
"status": "invalid event",
"message": "Event object is invalid",
"errors": [
"'event_action' is missing or blank",
"'routing_key' must be provided in the body, or provided in the headers using 'x-routing-key'"
]
}
If you'd also like to validate your routing key, you can send an acknowledge event with a dummy dedup_key:
curl --location --request POST 'https://events.pd-staging.com/v2/enqueue' \
--header 'Content-Type: application/json' \
--header 'Cookie: uid=rBGA1lymclmSzRCsAwO3Ag==' \
--data-raw '{
"routing_key": "<your_routing_key>",
"event_action": "acknowledge",
"dedup_key": "something_that_will_never_match_an_open_incident"
}'
{
"status": "success",
"message": "Event processed",
"dedup_key": "something_that_will_never_match_an_open_incident"
}
Note that this will not show up anywhere in the PagerDuty UI, but that could be what you'd want anyways.

Failed to exchange a code for an access token for creating zendesk instance in cloud element through API

Please help to create zendesk instance in cloud element by 3rd party api call
Created Zendesk account Created & configure as per in Link
Succesfully got Elements OAuth Information
{
"oauthUrl": "https://yoursubdoamin.zendesk.com/oauth/authorizations/new?response_type=code&client_id=zendesk_unique_identifier&redirect_uri=http://www.my_cool_app.com/auth&scope=read write&state=zendesk",
"element": "zendesk"
}
Getting error in API
curl -X POST
-H 'Authorization: User <INSERT_USER_SECRET>, Organization <INSERT_ORGANIZATION_SECRET>'
-H 'Content-Type: application/json'
-d #instance.json
'https://api.cloud-elements.com/elements/api-v2/instances'
instance.json
{
"element": {
"key": "zendesk"
},
"providerData": {
"code": "Code on Return the URL"
},
"configuration": {
"oauth.api.key": "<INSERT_ZENDESK_UNIQUE_IDENTIFIER>",
"oauth.api.secret": "<INSERT_ZENDESK_CLIENT_SECRET>",
"oauth.callback.url": "https://www.my_cool_app.com",
"zendesk.subdomain": "<INSERT_ZENDESK_SUB_DOMAIN>"
},
"tags": [
"<INSERT_TAGS>"
],
"name": "<INSERT_INSTANCE_NAME>"
}
Getting error "Failed to exchange a code for an access token"
This might be because, you might not have registered an app with zendesk to get back the access token. This can also happen if your element in Cloud Elements is corrupted, make sure you are using the inbuild element instance. Still if you are facing the issue, please mention the steps you followed

Getting list of users in Google Admin SDK

I have OAuth login in my app. After that I have access_token.
I check token in google token info service:
https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=<access_token>
And It returns:
{
"issued_to": "554651647288-tquejcu6mctplq4kin5dd9r81mtkg3vv.apps.googleusercontent.com",
"audience": "554651647288-tquejcu6mctplq4kin5dd9r81mtkg3vv.apps.googleusercontent.com",
"scope": "https://www.googleapis.com/auth/admin.directory.group https://www.googleapis.com/auth/admin.directory.orgunit https://www.googleapis.com/auth/admin.directory.user",
"expires_in": 3299,
"access_type": "online"
}
As you can see I have admin user directory permission.
Then I send GET request for getting information about user
curl -X GET https://www.googleapis.com/admin/directory/v1/users/test_user#test.com?access_token=<access_token>
And google returned me right user information. After that I decided to get list of users.
curl -X GET https://www.googleapis.com/admin/directory/v1/users?customer=my_customer&access_token=<access_token>
And google returned me:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
But I don't understand why google returned me so error.
Could you please help me with this problem?
Thanks.
There are two solutions here.
1.This is the simple one. Put the URL params in quotes. This should do the trick - (fake access token used)
curl "https://www.googleapis.com/admin/directory/v1/users?customer=my_customer&access_token=asdf.AHEasdfyIc9vuPQ_BGONpzEJkasdfWYXGujPw5iPI"
You don't need to pass in -X GET as that is the default.
2.In general it is bad practice to send the access_token in the URL as this URL may get logged somewhere along the way for innocuous reasons. You can also do this through HTTP Header of Authorization -
curl -H "Authorization: Bearer asdf.AHEasdfyIc9vuPQ_BGONpzEJkasdfWYXGujPw5iPI" https://www.googleapis.com/admin/directory/v1/users?customer=my_customer

Resources