Google Places API - Attempted Solution - google-places-api

There seems to be some confusion as to what is causing an error with Google Places API and using JSON as the output.
For example, the output (when pasting the URL into the address abr of your browser returns this:
{
"html_attributions" : [],
"results" : [],
"status" : "REQUEST_DENIED"
}
At first, I thought this may have something to do with my API Access Status set to 'Inactive' but after reading several posts here on SO...
REQUEST_DENIED Google Maps API v3 Places Error
Google Places API - REQUEST_DENIED
REQUEST_DENIED when using the Google Places API
...I am none the wiser. The aim of this post/thread is to try establish exactly the capabilities of Google Places API, whether or not the API Key is required, and why REQUEST_DENIED occurs so often for many users.

"status" : "REQUEST_DENIED" is returned when:
The sensor parameter is missing
The key parameter is missing
The sensor parameter is not set to true or false
There is a problem with the key parameter e.g.
You have not activated the Places API Service in your APIs Console Services Tab
Your API Key does not match the key in your APIs Console API Access Tab
Your API key has been compromised and blocked; you can generate a new API key in your APIs Console API Access Tab
The request is not sent as a HTTPS GET request
HTTPS is required for all Places API Web Service request
POST requests will only work for Places API Place Actions e.g Check-In and Event requests

Related

API Gateway error "Unsupported Media Type" when trying to accept application/x-www-form-urlencoded data

I am using the following tutorial:
https://www.twilio.com/docs/sms/tutorials/how-to-receive-and-reply-python-amazon-lambda
When I test the api in aws I receive a 415 error, Unsupported Media Type.
I assume this is related to the fact that Twilio sends its data in the form of application/x-www-form-urlencoded and AWS wants json.
The tutorial takes this into account. However, its code does not work for me.
I have searched the web, and tried numerous fixes to no avail.
The raw data from Twilio is (with sensitive information changed)
ToCountry=US&ToState=AK&SmsMessageSid=SM7777777777777777777777&NumMedia=0&ToCity=AAA&FromZip=99999&SmsSid=SM9999999999999999999&FromState=AK&SmsStatus=received&FromCity=BBB&Body=Is+this+json+&FromCountry=US&To=%2B15555555555&ToZip=88888&NumSegments=1&ReferralNumMedia=0&MessageSid=SM888888888888888888&AccountSid=AC6666666666666666&From=%2B14444444444&ApiVersion=2010-04-01
I enter this information in the body section of the test, run the test and the error is thrown.
There is also the same error when I try the actual webhook through Twilio.
I have also entered with surrounded in {}
I have also tried a jsonified version with the ampersands changed to commas, and the equal signs changed to colons with the items in quotes.
I also have tried:
{
"to_number": "+14444444444",
"from_number": "+15555555555",
"message": "hello does this API work"
}
I have also tried to add the following to the header of the test
"Content-Type": ["application/x-www-form-urlencoded"]
Many of the fixes I have tried involve changing the Integration Request mapping.
None have worked.
The one from the tutorial is:
#set($httpPost = $input.path('$').split("&"))
{
#foreach( $kvPair in $httpPost )
#set($kvTokenised = $kvPair.split("="))
#if( $kvTokenised.size() > 1 )
"$kvTokenised[0]" : "$kvTokenised[1]"#if( $foreach.hasNext ),#end
#else
"$kvTokenised[0]" : ""#if( $foreach.hasNext ),#end
#end
#end
}
And is of content type application/x-www-form-urlencoded
There is a stack on this topic:
Amazon Api gateway integration with Twilio
None of its solutions worked for me.
I thought the following was very promising, but it also failed for me.
https://gist.github.com/199911/68a43f83fd933b1e3ac6
I have also tried to change the lambda function. However I do not think it is the source. Its tests work.
Any help would be much appreciated.
Quote from AWS console:
You can configure binary support for your API by specifying which media types should be treated as binary types. API Gateway will look at the Content-Type and Accept HTTP headers to decide how to handle the body.
It sounds like you should configure your specific media type "application/x-www-form-urlencoded" under API gateway settings (Binary Media Types), which will tell the API gateway to accept that body type.
Navigate to Api Gateway Console:
Click on your API
On the left select settings (under API menu)
Scroll down and click Add Binary Media Type
Type application/x-www-form-urlencoded Click save
Hoping this will help.

Teams Tab API access to Sharepoint FIle Contents causing 405 on OPTIONS call

In Microsoft Teams, I have crated an App that lists files of a certain type in a Tab
The use case is that the contents of the file need to be read by my Javascript
the Javascript in the Tab already successfully gets an ID Token and Access Token (via ADAL)
this code already successfully lists the DriveItems in the group the current logged in user can see
via https://graph.microsoft.com/v1.0/groups/${groupId}/drive/root/search(q='{pdf}');`
when I attempt to GET the DriveItem via
https://graph.microsoft.com/v1.0/groups/${groupId}/drive/items/${itemId}/content
where the itemId is returned from the first call
I successfully see the HTTP 302 from the https://graph.microsoft.com endpoint redirecting to https://<thesharepointsite>.sharepoint.com/<etc>
Axios (and the Microsoft Graph Javascript API) are successfully traversing to the redirect
Postman, with the same https://graph... URL with the AccessToken successfully downloads the binary content from the 302 redirect (so it is not an Auth issue)
PROBLEM
in Microsoft Teams, inside my Tab, the browser (built inside of the Teams desktop app) HTTP calls to https://<thesharepointside>.sharepoint.com respond with a 405 error on the OPTIONS call
usually this means there is a CORS issue, and so the solution is to add the domain to the validDomains of the app
Attempted Solution
the Manifest has the following entries in validDomains
"validDomains": [
...
"*.sharepoint.com",
"graph.microsoft.com",
"login.microsoftonline.com"
]
manually add the full domain the the Teams App's Manifest
use the suggested "{teamsitedomain}" as per https://learn.microsoft.com/en-us/microsoftteams/platform/resources/schema/manifest-schema#validdomains
*.sharepoint.com as per above
use the Microsoft Graph Javascript APIs
In all instances, I get 405 on the OPTIONS call
No file download from within the Tab within Microsoft Teams.
Suggestions?
THIS MAY answer your question in the future
my code now does a https://graph.microsoft.com/v1.0/groups/${groupId}/drive/items/${itemId}
this is an Instance of DriveItem and returns a property on the JSON response:
#microsoft.graph.downloadUrl
as per Microsoft Graph API Download File content return Unauthorized 401 this is a short-lived URL you can traverse without Auth headers
the content of my file was returned successfully (no CORS issue)
I can now download the contents of the DriveItem within a Tab
I hope this helps someone

Need to exceed 1200 referrer url limit in Google Javascript API

So my colleague ran into this error while attempting to add http referrers to our javascript maps api key. Our app needs to be able to hit the api from our client domains, and there are well over 1200 of them. Has anyone hit this limit, if so, how have you surpassed it?

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.

yam.platform.request always fails with "No 'Access-Control-Allow-Origin' header is present on the requested resource"

I try to use the yammer api. I did everything like specified in the docs (https://developer.yammer.com/v1.0/docs/js-sdk):
I created my own Yammer app, with my website (https) domain set in the Javascript Origins
I use the login button to receive my Auth token.
I set the token with yam.platform.setAuthToken
But any following request with yam.platform.request fails with "No 'Access-Control-Allow-Origin' header is present" although I can see in the network console that the correct token is sent through the Authorisation Bearer Header.
I found out that my code was working when accessing my home-network. For accessing any other network that i am a member of, the Yammer app should be globalized, see yammer client application external networks 401
I think you don't need to set yam.platform.setAuthToken yourself - that is taken care of by yam.platform.getLoginStatus.
You can receive the token from the response object provided to the callback function passed to getLoginStatus if you need to, but if your JS queries the API from the browser itself, there is no need for that.

Resources