Im researching about some custom google API and in the site it seems to be running okay. im able to upload the desired file to my own drive account, but when i tried it to my local environment its not working. i already changed the developer's key. the oauth seems to be okay but the developer's key might have a problem. here is the demo that the guy provided. https://howdy39.github.io/google-picker-api-demo/ but when i tried it to my local environment its not working, any of them. here is a sample picture of the problem This happens after the login screen so the auth keys are okay. i dont know what to do with the developer's key. here is the original source code provided. https://github.com/howdy39/google-picker-api-demo/blob/master/docs/index.html
Please check Credentials - API key - Accept requests from these HTTP referrers (web sites).
Try adding localhost.
Related
I want to extend a project in a way that it can save files to Google Drive. To learn how this works I tried the Quick Start Example from the docs: https://developers.google.com/drive/v3/web/quickstart/js
Following the example I noticed that the example is creating an API key in the developer console. Following the same steps only returns a Client secret. I suspected this to be a naming problem and hoped that the two are the same.
Unfortunately, the example code does not work but loggs the following error:
{"error":{"errors":[{"domain":"usageLimits","reason":"keyInvalid","message":"Bad Request"}],"code":400,"message":"Bad Request"}}
In the request to:
https://content.googleapis.com/discovery/v1/apis/drive/v3/rest?pp=0&fields=kind%2Cname%2Cversion%2CrootUrl%2CservicePath%2Cresources%2Cparameters%2Cmethods%2CbatchPath%2Cid&key=[[my key]]
I checked that the right secret appears in the request url. Setting var API_KEY = '<YOUR_API_KEY>'; to an empty string is a workaround.
How can I debug this further? where do i get the right api key?
I run into this error recently. It is certain that Google Documentation is usually quite good, but in this case, the Google Drive API (https://developers.google.com/drive/api/v3/quickstart/js) it wasn't that clear. For this API in particular, you will require two credentials.
Under your project credentials section, you must create an OAuth 2.0 client for a web application and a API Key.
(Sorry for the Spanish in the screenshots)
Regarding the OAuth 2.0 client, not that I have restricted it to http://localhost
Concerning the API Key, note that I have restricted it to my Google Drive API
Then, in the index.html provided by the documentation, you can set your CLIENT_ID to the one obtained in the OAuth 2.0 client generation, and the API_KEY to the the one generated in the API Key process.
{"error":{"errors":[{"domain":"usageLimits","reason":"keyInvalid","message":"Bad Request"}],"code":400,"message":"Bad Request"}}
Means that the request you have made has not been properly authenticated.
API key is for accessing public data. Oauth2 client id and secret will be used to access private user data which file.list is. So i dont think this is a naming problem. Your code should be popping up requesting access of the user.
I have been looking for an open google api to get google authentication token by using a user's google username and password. I have came across google-auth node package. And according to it, I first need to log in to create a project in google developer console and then use the key to access the information.
But I want to know whether there is any open api where I can directly pass the username and password, without creating any project in google developer console. And get the authentication token as part of response.
This is my first project using google apis, so if it sounds naive please let me know the right way of authenticating a google account user using a node project.
Sorry, I can't provide any code, as I am stuck at understanding the initial part itself, about how to authenticate different users.
Thanks in advance
You can't use google or any social login, without first creating a project and using it's api key.
That is just how oAuth is designed.
I am trying to use push notification for my web site..
I am trying fcm. In the Google documentation (https://firebase.google.com/docs/cloud-messaging/js/client) they told us to use gcm_sender_id in manifest.json file, but I don't find it any where in firebase page https://console.firebase.google.com/project/fir-98798789/overview
Also they have mentioned
Don't confuse the "browser sender ID" with the project-specific sender ID value shown in your Firebase project settings. The browser sender ID for manifest.json is a fixed value, common among all FCM JavaScript clients.
The sender ID that you enter in the manifest.json of your web app is independent of your Firebase project. It is the same for all web apps (yours, mine, everybody's):
"gcm_sender_id": "103953800507"
So just copy/paste the line above into the manifest.json for your project. See this section of the FCM documentation.
Seems like Firebase Messaging actually works even if you skip this step. Look at https://web-push-demo-11213.firebaseapp.com as an example.
This demo website doesn't even have a manifest but is able to talk to FCM, get tokens, refresh them and so on.. Sorry you won't be able to actually send a push though since you don't know the auth key, but you get the idea - I've tested it, it works.
In light of this, not sure why this manifest requirement though.
Also, looking at the FCM SDK source on github, looks like they only throw an error if you have a manifest with a gcm_sender_id that's not 103953800507. For everything else (the gcm_sender_id field in manifest missing, or even the manifest itself missing from the website), it works as fine.
See the code here: https://github.com/firebase/firebase-js-sdk/blob/master/packages/messaging/src/controllers/window-controller.ts#L329-L355
Goto https://console.firebase.google.com -> select your project.
Settings -> Cloud Messaging -> Project credentials -> Sender ID
Hope this help!
I am trying to integrate Google Maps Javascript API with my Rails Web Application running on locally on a VM. I can't get the Javascript code from the API. The sample I am following is this.
https://developers.google.com/maps/documentation/javascript/tutorial?csw=1
And the error I receive while trying to load the code is this.
GET
https://maps.googleapis.com/maps/api/js?key=MY_KEY&callback=initMap
net::ERR_NAME_NOT_RESOLVED
Note I am sending my actual key in the call to API.
Already tried solution provided to this question
Google Maps v3 api for localhost not working
It is possible to create a Browser API Key for test purposes that only works only for your machines IP or localhost. However make sure you do not deploy that to production :)
Just go to google developer console and and add one. I believe you can also add one for something like: *localhost*. I've done that before for some of their other services.
It depends on if you are using Google Maps API for "work" or not. See these docs:
If you're switching from the free API services to a Maps API for Work implementation, you must remove the key parameter from your requests.
Link to above quote: See section on Client ID
I'm using fiddler to forward my local webserver over our local network to test on mobile devices etc.
static function OnBeforeRequest(oSession: Session) {
if (oSession.host.toLowerCase() == "192.168.1.100:8888") oSession.host="localhost:8020";
}
This works fine, except I can't get google maps to authenticate properly with my API key, the dreaded message:
Google has disabled use of the Maps API for this application. The
provided key is not a valid Google API Key, or it is not authorized
for the Google Maps Javascript API v3 on this site. If you are the
owner of this application, you can learn about obtaining a valid key
here:
https://developers.google.com/maps/documentation/javascript/tutorial#api_key
I know the maps api is working on my local machine since I've added "localhost" to the allowed referrers section on the google api console.
I have tried adding my global ip to this list, localhost:8888, localhost:8020 etc. to no avail.
Is there a good way to track which referrer google is picking up so I can add it to my 'allowed' list? I've tried 'document.referrer' in JS, but that returns blank both on local(maps working), and local network remote access (through fiddler, maps not working).
I'm not using PHP, so something in JS would be ideal; I assume this is possible since the google maps API is added as javascript!
Any help would be appreciated, Cheers.
I tried alert(location.host), and it just returned my local ip + port (192.168.1.100:8888)
I was able to actually solve this by changing how the google api accesses my API key.
I was including the key in my JS call on my html page, this is apparently no longer necessary and when I removed it, it worked across LAN.
It now reads:
<script src="https://maps.googleapis.com/maps/api/js?v=3&sensor=false">
Note, all I needed in my Google API referrers section was what I had beforehand:
http://localhost/*