REQUEST_DENIED using valid key and sample query from documentation - google-places-api

All my requests are denied. My troubleshooting has reached the point of running the sample query from the Places API documentation, like so:
https://maps.googleapis.com/maps/api/place/textsearch/xml?query=restaurants+in+Sydney&sensor=true&key=mykey
...with 'mykey' replaced by my recently-generated browser key from API console. Referers for my simple API access key is set to * to allow all. API console shows no known issues with my Places API use, which is turned on.

I should have left 'referers' blank, instead of *

Related

How to request full access when sign in using near-js

I've got a problem with signing in using near-js. I just call wallet.requestSignIn and it works but always I see that application request Limited access. There is nothing about Limited and Full access in documentation so I just guess that I should do something to request Full access
In order to keep your wallet secure, a web app signing in to NEAR should not request full access keys.
Instead you ask for an access key to the smart contract your web app is going to use, and you can also specify which method names on the contract that should be allowed calling ( see the methodNames property of the SigninOptions )

The Admin Directory users.list request returns 400 Bad request

This happens in the API Explorer and using the .NET client API. In the API Explorer, I was trying to use the query param, but eventually I just removed it and now send the request with no params, and it still turns around 400 even though I am authenticating successfully with OAuth2 in browser.
Why is this endpoint broken?
https://developers.google.com/admin-sdk/directory/v1/reference/users/list
The problem was the customer field was not filled in. It must contain a valid customer id. Once I populated that, it worked.
Really wish Google would work on providing better error feedback and improve their docs. This field (as of today) is still listed as optional.
As the documentation says:
either the customer or the domain parameter must be provided
I tried to specify domain name and it worked.

getting REQUEST_DENIED ("This service requires an API key.") but no error in the API console

I just added Google Places API Web Service to my project, added an API key (unrestricted, for testing) and I am copy pasting requests from the docs to try things out, for example:
curl https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJN1t_tDeuEmsRUsoyG83frY4&key=my_new_key
I only get Request Denied ("This service requires an API key."), but in the API console I do not see any errors. The key is really in the curl command line in my sample, the API is enabled in the console, the key is valid and not restricted. I cannot find a reason why this should not work?
Here are few things you could try...
API key is for the application but you should authorize that application in google before using it.
Check your API key again and see if theres any encoding required before using it.
Enable API from your google account.
See if theres any restriction on your API key for example :
Under Accept requests from these server IP addresses, enter the IP
addresses from which your key is to be accepted, one per line. You
may also enter a subnet using CIDR notation (e.g. 192.168.0.0/22).
Hope this helps..
Try this link.... very helpful
REQUEST DENIED with Google Places API KEY for Server Web used in an Android application

invalidSearchFilter when searching my videos using YouTube api v3

I keep getting invalidSearchFilter error when using YouTube API v3. I have the following params:
part: snippet
q: testtag
forMine: true
type: video
I am using the API playground, and noticed that if I do an OAuth call, it will work, but with just the API key (Execute without OAuth), it fails. Same thing happens in my code. A basic list call works in both, so I am suspecting a bug in their API, or I'm missing something.
Can anyone else confirm this to see if I'm missing something?
It works if I leave off the forMine and type params, but then it searches globally, which is not what I want.
I have searched for this, and the only other references I've found have been related to not setting the type param, but I have it set.
I found this link which suggests a possible API bug: youtube v3 api error when searching with forMine set to false
The documentation is your friend Search: list
forMine boolean This parameter can only be used in a properly
authorized request. The forMine parameter restricts the search to only
retrieve videos owned by the authenticated user. If you set this
parameter to true, then the type parameter's value must also be set to
video.
So yes you are missing something the part where you can only use forMime type parameter with authorized requests. Using an Api key is an unauthorized request you are accessing the public API. How do you think it would be able to search videos that yours if you aren't authenticated? It doesn't know who you are.

How to add multiple redirect URIs for Google OAuth 2?

I am trying to make Google OAuth 2 authentication work with a toy app I am running on my computer (at localhost:8080) using Social Auth for Java.
However when my app connects to Google to authenticate the user, Google responds with this error page:
My app, named "My Hobby App", is configured in the Developer Console as such:
In the Google OAuth 2 docs, it is specified that:
redirect_uri: One of the redirect_uri values listed for this project
in the Developers Console.
Determines where the response is sent. The
value of this parameter must exactly match one of the values listed
for this project in the Google Developers Console (including the http
or https scheme, case, and trailing '/').
I have a couple of questions:
How can I add multiple redirect_uris to my app?
Why is Google identifying my app as "Project Default Service Account" rather than "My Hobby App"?
It's actually easier than you think, unfortunately, it took me a couple of hours to figure it out.
How can I add multiple redirect_uris to my app?
Normally when you add multiple links to something on Google or elsewhere you separate it by , or ; but with Redirect URIs you have to use a new line, it's actually not very intuitive. So when you press the Edit Settings button, you can add to the URI and/or Origins if you have a couple more links, separated by newlines (enter).
No need for complicated app configurations or new keys.
Why is Google identifying my app as "Project Default Service Account" rather than "My Hobby App"?
On your second question: You have to go to the "Consent Screen" tab to change your app info such as your PRODUCT NAME, HOMEPAGE, LOGO, etc.
This answer may not be an exact answer to the question, but I think this might help those who are using Google OAuth for the first time and are wondering why their multiple URIs are not being recognized.
We use the redirect URI at 2 places in the code. First time, while fetching the auth code and a second time, when exchanging this code for an access token.
In the Google docs, it is clearly mentioned that the response for the auth code request(1st request) will be sent to the redirect URI. So, if you make the request from an endpoint A and specify the rediredt URI as endpoint B, Google will send the auth code to endpoint B. This is clear and worked fine without any errors.
Coming to the second request, the documentation is somewhat ambiguous. The redirect_URI parameter is described as below:
redirect_uri: The URI that you specify in the API Console, as described
in Set a redirect URI.
This is where I made a mistake in understanding how this works. Following a similar approach to the first call, I used a third endpoint C and passed this endpoint C in the redirect_URI parameter while making the second call. I got a URI mismatch error although my endpoints B and C are specified in the API console.
The problem is that, unlike in the case of first call, the response to the second call comes to the same endpoint from where the request is made. I made a request in python like below:
r = requests.post(token_endpoint, params)
r has the response with the token.
I was getting a URI mismatch because, I am supposed to use the same redirect_URI in both the calls.
So, for a single OAuth request, we need to use a single redirect_URI.
But then, that brings up the question, why are multiple redirect_URIs allowed in the API console for a single app. I am assuming that if we need to make multiple pairs of authCode-token calls in the same app, we have the leeway of using multiple redirect_URIs.

Resources