Google Spreadsheets API & localhost - google-api

I try to follow this :
https://developers.google.com/sheets/api/quickstart/js
to learn how to use the Google Spreadsheets API.
I have been careful to follow the directions but I must have missed something, since I get the following result :
"error": "idpiframe_initialization_failed",
"details": "Not a valid origin for the client: http://localhost:8000 has not been registered for client ID <YOUR_CLIENT_ID>. Please go to https://console.developers.google.com/ and register this origin for your project's client ID."
I declared http://localhost to be authorised origin for my client_id ...
I tried in vain all the suggestions given here :
Google Tag Manager API error "Not a valid origin for the client: http://localhost has not been whitelisted for client ID
Can someone tell me where this error might come from ?

Related

How to configure authentication from Azure data factory to Google Sheets

I am trying to fetch data from Google Sheets via the Azure Data Factory. I have a data flow configured, and a Google Sheets Linked Service configured as well. The Google Sheets Linked Service is using an API key that has no Application Restrictions, and for API restrictions, it is restricted to Google Sheets. When I test the connection, it is successful. However, when I try to fetch a spreadsheet using the data flow in debug mode, I get the error:
at Source 'GoogleSheetsOutput': Failure to read most recent page request: DF-REST_001 - Error response from server: Some({
"error": {
"code": 403,
"message": "The caller does not have permission",
"status": "PERMISSION_DENIED"
}
}), Status code: 403. Please check your request url and body. (url:https://sheets.googleapis.com/v4/spreadsheets/<my_spreadsheet_id>/values/Sheet1!A2:B3,request body: None, request method: GET)
I made a service account, and shared the google sheet with the service account e-mail, and I also shared it with the admin on the account, which is where the API Key was made.
Any ideas what I need to do here? I would also prefer to use oauth / service account instead if possible, so I am happy to go down that route if there is some documentation I can follow.
"error": { "code": 403, "message": "The caller does not have permission", "status": "PERMISSION_DENIED" }
I tried to repro this and got the same error.
To solve this, I changed access of my google sheets from restricted to Anyone with the link
It worked and data is previewed without error.

How to pull pubsub metrics from google api

We are using our own logging solution because stackdriver is su...bpar. I want to pull the metrics on how many unacknowledged messages there are in the pubsub. Started to read the docs on that and they are all over the place.
Found this page:
https://cloud.google.com/monitoring/api/metrics
Despite being under the api it does not describe any api calls, but does contain the description of the metric I want to extract.
Now I am thinking I need to use the monitoring api to extract what I need somehow:
https://cloud.google.com/monitoring/api/ref_v3/rest/
So I use the api explorer to try a couple of methods:
https://developers.google.com/apis-explorer/#search/monitoring/monitoring/v3/monitoring.projects.groups.list
I query and gives me an available url:
GET https://monitoring.googleapis.com/v3/projects/myprojectname/groups?key={YOUR_API_KEY}
I go to my project's console (api & credentials page) and generate an api key without restrictions and paste it in trying to curl.
curl https://monitoring.googleapis.com/v3/projects/myproject/groups?key=myrandomkeylkjlkj
{
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}
Why is this happening? How can I get the metrics? I went to the url provided but it explains oauth token creation and has nothing regarding the api keys. I just need to curl things to make sure I am going the right way.
Why does this have to be so hard? Killed several hours of my life trying to get this.
curl -H "Authorization: Bearer $(gcloud config config-helper --format='value(credential.access_token)')" https://monitoring.googleapis.com/v3/projects/myproject/groups

Prestashop / Google API error 400 invalid_request

I tried to connect the Google Analytics API to my Prestashop 1.6.1.11.
I created and install the Google Analytics, then configure the API Google Anlytics in v3.0 mode ( with OAuth 2.0 ), but each time I put the parameters (ID Client, secret key and Profile ), Google Analytics API redirect me to a 400 error with this message :
Error: invalid_request /
Invalid parameter value for redirect_uri: Missing scheme: modules/gapi/oauth2callback.php
I don't understand because when I create the API identification, I put the redirect URI like that :
http://www.websitename.com/modules/gapi/ouath2callback.php
And same for https, but still doesn't work
Did I miss something ? Thanks a lot in advance
It looks like you are using a relative URI "modules/gapi/oauth2callback.php". It needs to be the full, absolute URI, character for character identical to the URI you defined in the API Console, eg. "https://www.websitename.com/modules/gapi/ouath2callback.php". Also, don't use http for redirect URI. It's only a matter of time before plain text URLs are disabled for security reasons.

Google Verification API 503

The google verification api is giving me a 503 error "An unexpected error occurred. Please try your request again." whenever I try to verify a domain using the TAG_MANAGER method.
This occurs when I try to use the API via the PHP client library and also when I use Google's API explorer. However, if I log in to Google Webmaster Tools and add the site, using Tag Manager as the verification method, I am able to successfully verify myself.
I've attached debugging information from the API explorer below, but it's very light on detail. My support request in the webmaster central forum has been met with deafening silence, but I'm not sure where else to ask.
Request
POST https://www.googleapis.com/siteVerification/v1/webResource?verificationMethod=TAG_MANAGER&key={YOUR_API_KEY}
Content-Type: application/json
Authorization: Bearer ya29.iAC-QBa-7nzvS2lpFFmfcej2Y0suhiWHgS8SivKN9jpYWffljsRV7rbL
X-JavaScript-User-Agent: Google APIs Explorer
{
"site": {
"identifier": "http://unit1-28leanyerdriveleanyer.com",
"type": "SITE"
},
"owners": [
"loboyle#raywhite.com"
]
}
Response
503 Service Unavailable
- Show headers -
{
"error": {
"errors": [
{
"domain": "global",
"reason": "backendError",
"message": "An unexpected error occurred. Please try your request again."
}
],
"code": 503,
"message": "An unexpected error occurred. Please try your request again."
}
}
https://www.googleapis.com/siteVerification/v1/webResource?verificationMethod=TAG_MANAGER&key={YOUR_API_KEY}
may need to be
https://www.googleapis.com/siteverification/v1/webResource?verificationMethod=TAG_MANAGER&key={YOUR_API_KEY}
also, a few additional notes
For Google to use your Google Tag Manager container snippet code for Webmaster Tools verification, the code must be placed immediately after the opening tag of your page.
The method you provided is used for verifying a site or domain, be sure you intend to verify a site, because this is what your request currently contains.
This method requires you to be authenticated (OAuth 2.0)
http://code.google.com/apis/accounts/docs/OAuth2.html
Ensure you have visited the following link
http://www.google.com/tagmanager/features.html
I finally stumbled across the fix for this today. The problem was that the service account running the requests needs to have "View and Manage" permissions on the applicable Tag Manager account, not just on the container that is actually being used. Only view access is required to the actual container.
While this isn't exactly desirable (we have 20+ containers for different sites/applications within the one account), it does resolve the problem and allow the Tag Manager site verification to work as intended.
I'm not sure whether the documentation has been changed since I originally had this problem or whether I just missed it. The required permissions are unexpected and the response code is misleading (a 403 would make more sense).
Check if you've enabled "Maintenance Mode" on your domain you're trying to verify using Google. Disable it and you're done.

Google Books API server not accepting calls from Heroku server

I'm developing an application in JAX-RS on a Heroku server but I've run into issues making calls to the Google Books API from the server. I've been using the Java libraries provided by Google to make these calls and on some occasions it works but for the most part it returns this error
403 Forbidden
{
"code" : 403,
"errors" : [ {
"domain" : "global",
"message" : "Cannot determine user location for geographically restricted operation.",
"reason" : "unknownLocation"
} ],
"message" : "Cannot determine user location for geographically restricted operation."
}
I suspect that this issue is related to the dynamically generated IP address system Heroku uses for routing since the Google server is having issues detecting the origin of the API calls. How would I approach working around this? Is there any way for Heroku to use static IP addresses or could I use a proxy to act as the sole access point for the API?
Just realized that this can be resolved with adding a country code to the Google Books query (&country=US) or adding a x-forwarded-for header from the original HTTP request.
http://productforums.google.com/forum/#!topic/books-api/7FQ-622q-jI
Thanks a lot for the question ... and the answer :)
Just to add that it seems there is a way for Heroku to use static IP address with Proximo

Resources