Confusion regarding the enable option in Google API
in my account the google drive api is disabled but still when I authenticate a thirdparty app using oauth2.0 it can access my drive files. Then what is the use of this enable api.
1 answer
-
answered 2018-04-17 05:12
DaImTo
Cloud developer console is a place for developers to create applications. when you create a new application you must decide which APIs will be used by that application.
I authenticate a third party app using oauth2.0 it can access my drive files
Unless you are the developer of the third party application setting this will not have any effect on what applications created by other developers can do with your account. If you dont want them accessing your drive account then dont install any third party applications that request permission to access your drive account.
See also questions close to this topic
-
Callback not defined when accessing Google Sheets using service account
I am trying to access data from a public Google Sheet. The sheet has read-only access to anyone. I am using official Node.js client for this. I was using a service account to authenticate the request, as I am using the same service account for accessing another sheet which can't be made public.
The code was working fine, but as soon as I updated the Node.js client to the latest version, it started giving me strange errors. I have created a minified example for the error and here's the code for this -
/*eslint-disable no-console */ const { promisify } = require('util'); const GoogleAuth = require('google-auth-library'); const { google } = require('googleapis'); const googleAuth = new GoogleAuth(); const sheets = google.sheets('v4'); sheets.spreadsheets.values.getAsync = promisify(sheets.spreadsheets.values.get); async function authorizeWithServiceAccount(serviceAccountKey, scopes) { try { let authClient = await authorize(serviceAccountKey, scopes); return authClient; } catch (err) { console.error(err); throw err; } } function authorize(credentials, scopes) { return new Promise((resolve, reject) => { googleAuth.fromJSON(credentials, (err, client) => { if (err) { console.error(err); reject(err); return; } client.scopes = scopes; client.authorize((err, result) => { if (err) { console.error(err); reject(err); return; } console.log(result, true); resolve(client); }); }); }); } async function getData(auth, spreadsheetId, range) { try { return sheets.spreadsheets.values.getAsync({ auth: auth, spreadsheetId: spreadsheetId, range: range }); } catch (e) { console.error(e); throw e; } } const serviceAccountJson = require('../configs/keys/service_account'); //The service account json key const spreadsheetId = 'SPREADSHEET_ID'; // Id of the sheet I am trying to access const apiKey = 'THE_API_KEY'; //Any API key generated on Google's API console const range = 'A:M'; async function init() { let authClient = await authorizeWithServiceAccount(serviceAccountJson, [ 'https://www.googleapis.com/auth/spreadsheets.readonly' ]); return getData(authClient, spreadsheetId, range); //This doesn't work and throw error // return getData(apiKey, spreadsheetId, range); //This does work and return all the data. } init() .then(result => { console.log('Received Data'); console.log(result.data); }) .catch(e => console.error(e));
So if I use API key instead of the service account as auth parameter, I get proper data as expected. But as soon as I use a service account instead,
result.data
becomesundefined
and then I get this error.TypeError: callback is not a function at JWT.OAuth2Client.postRequest (/Volumes/Projects/Work/node_modules/google-auth-library/lib/auth/oauth2client.js:341:9) at postRequestCb (/Volumes/Projects/Work/node_modules/google-auth-library/lib/auth/oauth2client.js:297:23) at Request._callback (/Volumes/Projects/Work/node_modules/google-auth-library/lib/transporters.js:113:17) at Request.self.callback (/Volumes/Projects/Work/node_modules/request/request.js:186:22) at emitTwo (events.js:126:13) at Request.emit (events.js:214:7) at Request.<anonymous> (/Volumes/Projects/Work/node_modules/request/request.js:1163:10) at emitOne (events.js:116:13) at Request.emit (events.js:211:7) at IncomingMessage.<anonymous> (/Volumes/Projects/Work/node_modules/request/request.js:1085:12)
I was using googleapis library version 25.x before and at that time service account auth was working, but as soon as I updated it to 28.x, it stopped working.
Is there any way I can use service account instead of API key in the 28.x googleapis node.js client? I can't downgrade it since I am using other Google APIs which require the latest version.
-
Google doesn't send Push-Notifications
I'm using Google Calendar API in my application.
The problem that I faced is that Google doesn't send me Push-Notifications.
- I setup my app here https://console.developers.google.com/
- Verified domain: https://console.developers.google.com/apis/credentials/domainverification
- Watched calendar: https://developers.google.com/calendar/v3/reference/calendarList/watch and got successful response.
However, having done all of this, no push-notifications are received by my web-hook. It seems that Google just doesn't send them. Maybe I missed some step? I use https URL.
-
How to set local database for google safe browsing update API (v4)?
I am building a service for checking for phishing or malware URLs for one of my applications. This service will be running on google app engine. Now, I want to use google safe browsing's Update API (v4) to have local database of URL hashes. But I am having hard time to understand the setup process of the local database they have mentioned.
https://developers.google.com/safe-browsing/v4/local-databases
They do provide a Go source code to do something of this sort but its not descriptive enough to have my own implementation. I want to setup the db on google cloud itself. Can anyone point me to any good documentation or some ways to do the same if you have tried this before.
-
Google Storage Transfer Service cost-efficiency
I need to backup my aws s3 bucket with lots of files (800k files, 400GB) to google cloud storage. Google Storage Transfer Service seems like an easy solution but i have some doubts about cost-efficiency.
First time it will download a whole s3 bucket:
- 400 GB outgoing traffic on aws
- 800k get requests on aws
- 800k put requests on google storage
What about the second time and later?
It will cost the same as first time or it will download only changed/new files?
-
error uploading to cloud storage using a cloud function
I am trying to upload files to google cloud storage using a cloud function. However when the cloud function sends the file to be uploaded I often (although not always) get the following error
ERROR uploading to storage: { ApiError: Anonymous caller does not have storage.objects.create access to bucket_name/folder/test.jpg.
I am not sure why this error occurs - and why only some of the time
Here is the code:
const storage = require('@google-cloud/storage')(); function uploadToStorage(filepath, folder, filename) { const options = { destination: bucket.file(`${folder}/${filename}`), public: false, resumable: false }; storage .bucket(BUCKET_NAME) .upload(filepath, options) .then(function () { console.log(`${filename} uploaded to ${BUCKET_NAME}`); }) .catch((err) => { console.error('ERROR uploading to storage: ', err); }); }
Thanks
-
How can i pass config file parameters in Google Cloud Platform Spark Scala jobs?
I have a Spark Scala job deployed on GCP Dataproc cluster. How can I pass config file as a parameter to the Spark Submit query using the Web UI?