google-api-js-client

Google Sheets API Write to sheet not working when put on page that has Read from script

爱⌒轻易说出口 提交于 2019-12-24 05:09:07
问题 I am having problems writing to a Google Sheet and I can not figure out why. I am new to using this API and have been using the Google API Client Libraries Guides, for the JavaScript client library. I am trying to build a "Sign In" webpage that keeps track of when someone attends an event. When my page loads it pulls first and last name from a Google Sheet, then displays a list of those names. I want to be able to click on someone's name which would then update the same Google Sheet by

TypeError: Cannot read property 'gmail' of undefined

大城市里の小女人 提交于 2019-12-23 23:17:46
问题 let fs = require('fs'); let google = require('googleapis'); getMessage(userId, messageId, callback) { let gmail = this.getGmailService(); var request = google.client.gmail.users.messages.get({ 'userId': userId, 'id': messageId }); request.execute(callback); } when I call this method from a spec getMessage('abcd123987@gmail.com', '15934550ay626ud09') it spits out the following error TypeError: Cannot read property 'gmail' of undefined any comments/suggestions? 回答1: There are 3 options: 1. You

Make google auth request gapi.auth without a popup

余生颓废 提交于 2019-12-22 05:19:26
问题 Need to make auth request in js but the browser does not support popups. Is there any way to redirect to a new url or show the request in the in html5 page of the application 回答1: By using this code check if user authorized your app gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: true}, callbackAuthResult); Note: immediate:true if you set immediate true then it wont show popup. You see? You don't open the popup, and manage the stuff in the callback. This callback is

Unable to get access and refresh token after authenticating with Google API

冷暖自知 提交于 2019-12-21 20:44:08
问题 I followed this awesome tutorial to get the access and refresh tokens once the user logged in with their google account, but I always this response when I call GetAccessCode() : { "error": "invalid_request" } Here's my code: var url = window.location.href; if (url.indexOf("code=") > 0) { //Once the user signed in with Google var code_starts = url.indexOf("code="); var code = url.substring((code_starts + 5), url.length); alert("Code= " + code); GetAccessTokens(code); } else if (url.indexOf(

Google Contacts API with Google JavaScript Client Lib

拜拜、爱过 提交于 2019-12-18 12:24:14
问题 I am trying to work with the Google Contacts API v3. Because of the OAuth2 authentication and authorization I'm started with the Google APIs Client Library for JavaScript. I have no problems with that part of the API access. But after doing the auth part I don't know what to do next. Can I use the google-api-javascript-client for the Google Contacts API v3? In the list of the supported Google APIs by the javascript-client the contacts API does not appear. But I have full access with the OAuth

How does Google's javascript API get around the cross-domain security in AJAX

穿精又带淫゛_ 提交于 2019-12-17 22:42:19
问题 How does Google's API make cross-domain requests back to Google, when it's on your website? 回答1: They get around it by dynamically injecting script tags into the head of the document. The javascript that is sent down via this injection has a callback function in it that tells the script running in the page that it has loaded and the payload (data). The script can then remove the dynamically injected script tag and continue. 回答2: The accepted answer is wrong. Ben is correct. Below is the

Google OAuth 2.0 - Incremental authorization with offline access

狂风中的少年 提交于 2019-12-13 18:07:11
问题 I'm trying to implement incremental authorization with Google Oauth2 in my application. At first, when users sign in, the application is requesting some scopes and offline access. I'm generating and storing the refreshToken in my database so I can refresh access tokens to make API calls when needed. Now I'm going to implement a new functionality that will request a new scope, but I would like to ask for this scope only if users try to use this new functionality. The problem I'm facing is that

Use gapi.client javascript to execute my custom Google API

眉间皱痕 提交于 2019-12-13 00:27:59
问题 I have a service that is successfully deployed to Google Endpoints and it is accessible through browser. Now I am trying to load Google API javascript client library to call my services using javascript. As far as I know, I should do this gapi.client.load([MY_APP_NAME], 'v1', function() { var request = gapi.client.[API_NAME].[SERVICE_NAME].[METHOD](); request.execute(function(jsonResp, rawResp) {...}); ); But I always get an exception at run time complaining about gapi.client.[MY_API_NAME] is

Google Drive v3. Nodejs Resumable Upload creates untitled file in wrong directory

妖精的绣舞 提交于 2019-12-11 16:49:38
问题 Hey I have followed the steps from the Drive quick start guides and generated a token.json using the following scopes: const SCOPES = [ 'https://www.googleapis.com/auth/drive', 'https://www.googleapis.com/auth/drive.appdata', 'https://www.googleapis.com/auth/drive.file' ]; I am then running the following code to try and create/upload a file to google drive. async function testing() { let driveFolder = 'FOLDERID'; let res; try { const oauth2Client = new google.auth.OAuth2( credentials.client

Google drive: Get (root) file and folders with javascript api (get only deleted files on drive)

≯℡__Kan透↙ 提交于 2019-12-11 06:15:02
问题 Have the authorization part finished yet and works ok (no errors etc). After this I want to get the folders and files from the root of the drive. Starting first to get the files in the root (the procedure is rather similar to get the folders using children instead). I have designed the following code (according to the google example that produces a similar result), this is a part of my drive class: o.cdGetCloudFiles = function(fCallback, sFolderId ) { var oDefQ = {q:'trashed=false',