Do you have to get Drive permission in a Google Chrome Extension in order to call the Drive API?

My Extension has the following permissions called out in the Manifest:

"oauth2": {
        "client_id": "425460661917-smaehlat7c66p1ns6t90ssj3jmlrrecm.apps.googleusercontent.com",
        "scopes": [
            "https://www.googleapis.com/auth/userinfo.email",
        "https://www.googleapis.com/auth/userinfo.profile",
            "https://www.googleapis.com/auth/drive.readonly"
      ]
  },

I only want to use Google Drive when a user explicitly grants permission. I am only interested in file metadata at this point, so when the user indicates it, I used an Ajax call to get the metadata:

$.ajax({
              type: "GET",
              beforeSend: function(request) {
                request.setRequestHeader("Authorization", "Bearer " + token);
              },
              url: "https://www.googleapis.com/drive/v3/files/" + googleFileID + "?fields=sharingUser",
              dataType: 'json',
              processData: true,
              success: function(gDocsMeta2) {// then code...

This works great.

However, every user does not want to use my app with Drive, but (I think) because of the ‘drive.readonly’ in the manifest, understandably, Chrome periodically pops a permission request.

Is there a way to get more situational permission? With my existing code, when the user DOES request data from Drive a permission is popped…

Any help/direction appreciated.

How to force the Google API/OAUTH consent screen?

I have a Chrome Extension that, in the manifest, includes the Drive API. On install, when the user opens a Google Doc, background.js pops the consent screen to get the user’s permission to access their Google Drive.

This works fine on install. But if the user removes the app from Drive the code does NOT pop the consent screen again – it just gets a token and tries Drive only to get a 401 error.

I would have thought the auth call would pop consent if it isn’t granted…

Obviously if a user removes your app you shouldn’t keep asking for permission, necessarily – I’m just trying to deal with the simplest situation for now.

Some of my users never saw the consent page, or saw it and closed it…and are not prompted again.

Manifest:

"oauth2": {
        "client_id": "xxxxxxxxxx-smaehlat7c66p1ns6t90ssj3jmlrrecm.apps.googleusercontent.com",
        "scopes": [
            "https://www.googleapis.com/auth/userinfo.email",
        "https://www.googleapis.com/auth/userinfo.profile",
            "https://www.googleapis.com/auth/drive.readonly"
      ]
  },

Background.js:

googleFileID = getIdFromUrl(activeURL);

chrome.identity.getAuthToken({ 'interactive': true }, function(token) {

  console.log('In Chrome Identity and obtained token: ' + token);

  $.ajax({
    type: "GET",
    beforeSend: function(request) {
      request.setRequestHeader("Authorization", "Bearer " + token);
    },
    url: "https://www.googleapis.com/drive/v3/files/" + googleFileID + "?fields=owners",
    dataType: 'json',
    processData: true,
    success: function(gDocsMeta1) {
      // DO STUFF

Google API Console:
I have set up the API and can see traffic, although 10% of my traffic is errors, which I attribute to the above problem.

I use Google Firebase for user authentication…if that is relevant. While some of my users opt for Google Authentication to create accounts, many use email signup. The problem afflicts both types of sign ups.

Any help appreciated!

Is there any google API which could save gmail message attachments to google drive?

How can I save gmail message attachments to google drive. Is there any such google API?

Is there any way we could move gmail attachments to google drive in gmail chrome extension?

I have a gmail chrome extension which loads attachments of a specific email message. I used https://developers.google.com/gmail/api/v1/reference/users/messages/get api to get message details which also gives the detail of attachments if available. Json response for attachment looks something like below:

{
"partId": "1",
"mimeType": "text/plain",
"filename": "desolate-temple-64198-logs-1510662651275.txt",
"headers": [
 {
  "name": "Content-Type",
  "value": "text/plain; charset="US-ASCII"; name="desolate-temple-64198-logs-1510662651275.txt""
 },
 {
  "name": "Content-Disposition",
  "value": "attachment; filename="desolate-temple-64198-logs-1510662651275.txt""
 },
 {
  "name": "Content-Transfer-Encoding",
  "value": "base64"
 },
 {
  "name": "X-Attachment-Id",
  "value": "f_j9zmd99r0"
 }
],
"body": {
 "attachmentId": "ANGjdJ_rvtvA5vxbsywlxgUCZWlFly6-SJWFAjZmhspKuyX_9hGC7Qjr_84XkubQzNbYqTlsn4N2dCwah2F8vW8pGfADu803NjK1d-Wo_OpxXxgMt8IVGe_PENQtbeYMKcjKKe3C_oddNBEFmXPhzZRiBM6znm8rUWggLV7g6KPd8X0D2emJmrPS-KJJrsR23AQjlVvJmWoRJNJ7foH7TrQJ3Vb7HR8AL6AbOnC-0xKXFHf7C4QHOuRMA8NW9GjZDGOIkfcRL0CsnKMrKbqEK3o8GXkM6ohtniL0BM-k1qcdcERxSVQwiNgfDmcpUgQwT-KWrg66xVYHf1j8wGQgwbhaYfHkeUmCXjN_oJedlBSJv8PCGckEPHkt08M6wpyigNWXZzjcZCwNyfB5GasB",
 "size": 77518
 }
}

Now, I want to move this attachment to google drive. Is there something that I can do with attachment Id? I found that passing attachment id to https://developers.google.com/gmail/api/v1/reference/users/messages/attachments/get this api, I could get the attachment data in base64url encoded string. But I do not see any way to move this attachment to google drive. How can I achieve this?

Chrome extension – Where to save big data

I’m a developer of an extension with more than 15000 active users.
Many users ask for a sync feature.
Well, I have done some calculations and found out that each user has about 8 MB data to sync.
It is more than 100 GB.
Where they can be saved?
The extension is free and there is no way to monetize it to pay for a server.
The Google Drive does not allow to save into App Data from extensions.
Are there another ways?

Chrome extension – Where to save big data to sync

I’m a developer of an extension with more than 15000 active users.
Many users ask for a sync feature.
Well, I have done some calculations and found out that each user has about 8 MB data to sync.
It is more than 100 GB.
Where they can be saved?
The extension is free and there is no way to monetize it to pay for a server.
The Google Drive does not allow to save into App Data from extensions.
Are there another ways?
Google has no service to save data of its users?

Is it possible to rename Google Drive file from the file url ID?

I have the url of google drive file like,”https://drive.google.com/file/d/0BXXXXXXXXXXXXXXXXXXX/view”.

As topic,is it possible to change the google file name to “0BXXXXXXXXXXXXXXXXXXX” except for using the “copy and paste” way?

Google Chrome crashed and went into a crazy feedback loop, deleted my extension

I am trying to write a chrome extension that when activated, will add a UI on top of google drive that will allow for the easy mass-sharing of files. I have the UI part working using an inject.js script, but authenticating with the Google Drive API has been tricky. I found an issue where the gapi.client.init() function never returns and is left hanging. This is a known bug with the drive API, and I have been giving the developers information to help them fix it on the github page. However, I need a working prototype soon, and can’t afford to wait around for the issue to be fixed. I looked around and found that chrome provides its own way to authenticate via chrome.identity, and while it requires a user to be signed into chrome to function, which I don’t want, I thought it would work temporarily. Following the steps on the Google api page, I added my clientid to the manifest file, and tried to call chrome.identity.getAuthToken. When doing so, chrome redirected me to a “sign in to chrome page”. The issue is that after signing in, the page redirected me AGAIN to the same sign-in page, putting it into a loop. Whenever I tried to go to another tab or even try to launch the task manager, chrome would snap the focus immediately back to the sign-in page, effectively taking control of my entire system. The only way I could find to stop it was to remove the app from chrome via the button in the top right.

I searched stack overflow and found someone with the same issue. The answer there told me to make sure that the “key” property in the manifest file was the same as the appid when it was packaged, so I packaged my extension and looked for the key in the Default folder in appdata. I put that key in the manifest file and went into the chrome extension manager. I disabled the packaged extension and reloaded the unpacked one to refresh the manifest file, but when I pressed the button it disappeared from the menu. I clicked the button to add the unpacked extension back to chrome, and it deleted my extension! I don’t mean that it removed it from chrome, I mean it actually removed the extension from my local file system, which in my opinion is a huge security and integrity violation.

Luckily I have the file on version control, but I lost the changes I had made to use chrome.identity. At this point, I am not comfortable trying to use it again, because Chrome has been behaving horribly, but I can’t use the standard drive api because of the bug with init.

Can anyone tell me what I’m doing wrong, or at least what I can do to get authorization temporarily working in some capacity so I can demonstrate what I’ve worked on thus far?