After getting an access-token, I don't know how to use google API.
I tried to add 'access_token' but the error message displays 403: the request cannot be identified with a client project. Please pass a valid API Key with the request.
so I mixed up because I didn't get any API Key from OAuth. Please, does anyone knows how to get valid API key?
Have you looked at Using OAuth 2.0 for Client-side Web Applications?
The process is described quite nicely there. If you successfully received and verified the access_token, you can scroll down to Calling a Google API to see how to make API calls using the access_token.
If you need help with using a specific Google API, visit that API's documentation page. (e.g. Maps API, Drive API etc.)
Make sure you have needed APIs enabled and relevant credentials set up correctly from the Google API Console
You have to provide the api key along with the url; to do that just add the parameter "key=API_KEY", for example:
sheets.googleapis.com/v4/spreadsheets{{spreadsheet ID}}/values/{{the name of the spreadsheet}}!A1:D3?key={{API_KEY}}
Related
I am trying to get google reviews for my business but struggling with implementing it. Can someone share how to get the latest/top 5 reviews using google business API using JavaScript/Postman? I was trying to do so:
GET:
https://accounts.google.com/o/oauth2/auth?client_id=MY_CLIENT_ID.apps.googleusercontent.com&client_secret=MY_CLIENT_SECRET&scope=https://www.googleapis.com/auth/business.manage&response_type=token&redirect_uri=https://developers.google.com/oauthplayground
but it doesn't work.
Was trying also testing it on Google oauth playground
filling:OAuth flow: Client-side
Use your own OAuth credentials: my Client ID here
Step 1:
Authorize API: https://www.googleapis.com/auth/plus.business.manage
but here I am getting:
Error 400: redirect_uri_mismatch
The redirect URI in the request, https://developers.google.com/oauthplayground, does not match the ones authorized for the OAuth client. To update the authorized redirect URIs, visit: https://console.developers.google.com/apis/credentials/oauthclient/938304287177-nkvm5mqk3f5uq9lt9j2srqlgd0bjihip.apps.googleusercontent.com?project=938304287177
The redirect uri in your project on Google cloud console must exactly match the redirect uri you are sending from The easiest solution is to go to your project and add it.
https://developers.google.com/oauthplayground
Which is not the same as as you have an extra slash on the end
https://developers.google.com/oauthplayground/
This video will walk you though it. Google OAuth2: How the fix redirect_uri_mismatch error.
Question from Comments
how can I get the reviews using just API key without a need to authorize it using gmail account?
If you check the documentation Method: accounts.locations.reviews.list you will find that it says the following
API keys only allow you to access public data, the data you are trying to access is private user data and therefore requires authorization in order to access it. You can not use an API key to access this data you must be authorized using one of the above scopes. A video which explains api keys. Everything you need to know about Google API Key's, and where to get one.
I've started getting this error from a Google Maps widget within a CMS I use:
This API key is not authorized to use this service or API. Places API error: ApiTargetBlockedMapError
The error message provides a helpful link to this page, which includes the following text:
ApiTargetBlockedMapError Error
The Maps JavaScript API has not been authorized for the used API key.
Please check the API restrictions settings of your API key in the
Google Cloud Platform Console.
See API keys in the Google Cloud Platform Console. For more
information, see Using API Keys.
I know Google has tweaked this API in the past, so I went to the console and checked the permissions given for the key I am using. It includes these four permissions, include the Maps JavaScript API permission:
Geocoding API
Maps Embed API
Maps JavaScript API
Maps Static API
The only part not working is the address auto-complete. When I change to Don't Restrict Key mode so the key works with all services, it works fine. Any idea which service checkbox I might be missing? I'm wondering if Google is just displaying the wrong error.
Any ideas?
This is what I did. Updated.
Make sure you have enabled all the next Google Maps Services
If you have key restrictions, make sure you add the services like the next image..
Restart the project. It worked.
It turns out that Google has tweaked their permissions settings without updating the error. I had to give access to the Places API as well for the autocomplete to function.
I've submitted a PR to the CMS widget's documentation:
https://github.com/Frojd/wagtail-geo-widget/pull/59/files
I keep getting in to a loop of only seeing google's OAUTH documentation when searching for this but I don't want any user interaction. Maybe it's not possible. I want to do something like the code below in a http GET like you do with the maps API and receive a JSON reply
https://www.googleapis.com/admin/directory/v1/users?domain=MYDOMAIN&maxResults=200&key=MYAPIKEY
When I try something like the above I get 401 login required. I'm using vue-resource to make the request if that is relevant.
If it is possible could someone post an example of a correctly formatted request?
Based on the documentation available at https://developers.google.com/admin-sdk/directory/v1/guides/manage-users you should be able to do this with a simple get request however it MUST be authorized with OAUTH 2.
As stated at https://developers.google.com/admin-sdk/directory/v1/guides/authorizing "Your application must use OAuth 2.0 to authorize requests. No other authorization protocols are supported."
I haven't used vue-resource before however I know that the Chrome plugin Postman has an authorization option to target OAUTH2.0 which should be a good place to start and perform a quick proof of concept.
Once you have the proof of concept working and understand how to interact with OAUTH you can look at implementing it in your app.
I am trying to render google maps with the following link inside QlikView application
http://maps.google.com/staticmap?center=23.01,84.49&zoom=5&maptype=roadmap&size=640x400&key=XXXXXXXXXXXXXXXXXXXXXX&.jpg
(I have created a BROWSER API key)
The error message I am getting is (not in QlikView, but in browser, when I try to render the link using browser):
The Google Maps API server rejected your request. This site or IP is not authorized to use this API key.
I have actvated following Google services on my account:
Google Maps Android API v2
Google Maps JavaScript API v3
Static Maps API
Translate API
Already found this thread on StackOverflow: The Google Maps API server rejected your request
I have tried the following:
make sure the Referers is set to Any referer allowed
Make sure you have enabled "Static Maps API" service in addition to "Google Maps API".
Unfortunately, I am still getting the same error message.
Can anyone help please? Thanks.
generate key from https://console.developers.google.com/ for maps api of type browser key. And make sure that while calling document.referrer should be set to your domain.
Google API keys are binded to Domain Names, if you request a Google Service from a site that is not whitelisted the request gets tossed.
Go to your Google Console. https://console.developers.google.com/
Click in the left Menu API's & Auth then Credential
Under Public API access click create new key and choose on the next Page Browser Key. You are now forced to enter all Domain Names that are allowed to make API request with this key.
Enter your Domain names use the new key and you should ready to go.
I'm having some issues understanding the differences between an API Key and a Developer's Key when it comes to utilizing the YouTube API.
My application is using the restful requests in v3 of the Youtube API and I can set an API key via the gapi.client.setApiKey() function , which I have done during development, but when I was looking at the quotas, https://groups.google.com/forum/?fromgroups=#!topic/youtube-api-gdata/e1JDQ4lqbXU, it states that they are tied to a developer key instead and that the developer key should be sent with each request. I went ahead and got one for development purposes, but I'm not sure how they interact with each other.
I also didn't find any details on how to send the developer's key with each restful request (such as gapi.client.youtube.channels.list), only how to include it in the header or query string when making a regular get request.
Can someone help me understand the difference between the two, how they are related, whether I need both, and how to use them in restful requests, or if I need to switch to regular get requests?
Sorry for the confusion.
"Developer keys" refer to keys that worked with v1 or v2 of the YouTube Data API. You can obtain them here. There's a separate quota system in place for v1/v2 and yes, developer keys do come into play there.
"API Keys" refer to keys that you use when making unauthenticated requests using v3 of the YouTube Data API. (If you're making an authenticated request, you don't include an API Key, since the OAuth 2 client id/secret identifies your application.) You get an API Key that you could use with YouTube from the Google APIs console, after turning on the YouTUbe Data API v3 as one of the Services you're using. Quota in v3 is tied to your API Console project, and your API Key identifies which project you're using.
The takeaway is that if you're making unauthenticated YouTube Data API v3 calls, you should only include an API Key from the Google APIs console in your request. If you're using the JavaClient library, that's done via gapi.client.setApiKey().