Jose-cd / React-google-drive-picker

58 stars 70 forks source link

file picker not opening #20

Open Knightabhi opened 2 years ago

Knightabhi commented 2 years ago

I am getting a 200 response code but in response this is present {"valid":true,"blocked":true,"suppressed":false}

no error in the console either. Any suggestion or code that is working (version of the package that is working) I just need the file id of selected file to download through a batch job

thank you

rajesh-twg commented 2 years ago

I am also stuck at the same point, I have migrated gapi authentication to GSI but the picker does not open after authentication nor is it given any error in the console or elsewhere.

@Knightabhi @Jose-cd @Jose-DM could you please look into this for me, thanks in advance.

Knightabhi commented 2 years ago

I have used gapi directly without this package in react it is working now. just use google sample code for javascript. You have to do some changes

rajesh-twg commented 2 years ago

I have used gapi directly without this package in react it is working now. just use google sample code for javascript. You have to do some changes

This sounds good, could you please list briefly the changes you did.

Knightabhi commented 2 years ago

refer to https://developers.google.com/drive/picker/guides/sample

add this to index.html

add this inside useeffect const SCOPE = "https://www.googleapis.com/auth/drive"; const gapiLoaded = () => window.gapi.load('picker',gisLoaded(), intializePicker); function intializePicker() { pickerInited = true; }

function gisLoaded() {
  tokenClient = window.google.accounts.oauth2.initTokenClient({
    client_id: "",
    scope: SCOPE,
    callback: "", // defined later
  });
  console.log(tokenClient)
  gisInited = true;
  }

const script = document.createElement('script');

script.src = "https://apis.google.com/js/api.js";
script.async = true;
script.defer = true;
script.onload = gapiLoaded;

document.body.appendChild(script);

console.log("google loaded");

return () => {
    document.body.removeChild(script);
};
Knightabhi commented 2 years ago

The rest is the same from the sample javascript

rajesh-twg commented 2 years ago

@Knightabhi I am still unable to keep things in place properly in reactjs project, could you provide an index.html and App.js file with a minimum piece of code to open the picker. It's urgent. I am being around it since last month.

The error I am unable to fix yet is, 'google' is not defined while calling the createPicker function in App.js.

Knightabhi commented 2 years ago

use window. in front of google for every such error

rajesh-twg commented 2 years ago

after using a window with all the not defined variables, the picker is opening but still getting this error. image @Knightabhi

Knightabhi commented 2 years ago

Did you enable file picker API in your project? If not, do it, I think, then it will run.

rajesh-twg commented 2 years ago

I have enabled it, yet the same issue.

Knightabhi commented 2 years ago

can you share your code

rajesh-twg commented 2 years ago

These are App and index file. I am using ReactJs project and my node is v17.8.0 App.txt index.txt

Knightabhi commented 2 years ago

App.txt

Knightabhi commented 2 years ago

I have modified paste it and put client id

Knightabhi commented 2 years ago

you will need api_key and app_id

rajesh-twg commented 2 years ago

image google is still undefined :(

rajesh-twg commented 2 years ago

Could you please once verify the index.html file

Knightabhi commented 2 years ago

index.txt paste this

https://meet.google.com/nga-pqou-zmo

rajesh-twg commented 2 years ago

Joined the gmeet - are you there?

V7074 commented 2 years ago

In version 1.2.0 everything works. Check it

rajesh-twg commented 2 years ago

Thanks, @V7074 and @Knightabhi , I have set up the react project, and am able to play with the picker properly, Now I want to upload the complete folder (i.e. recursively, upload all the subfolder if there are any). But it is allowing to upload files only, I want to upload a complete folder, recursively as well if it has any subfolder.

twgadmin commented 2 years ago

@V7074 @Knightabhi it's urgent, can we somehow upload the whole folder into the drive using picker?

V7074 commented 2 years ago

@rajesh-twg @twgadmin Hi, guys. I’m no longer studying the topic related to google drive picker, so I can’t help you with your questions, sorry.

Knightabhi commented 2 years ago

I am not sure. Maybe you can get the location where the user wants to upload from the picker and then use drive API to upload the folder.

rahul-vyavahare commented 2 years ago

Hi,@Knightabhi already tried solution you suggested above (app.txt ) but still getting error/issue(picker api in google console is enabled). urgent help please @Knightabhi . image image

rajesh-twg commented 2 years ago

Hi,@Knightabhi already tried solution you suggested above (app.txt ) but still getting error/issue(picker api in google console is enabled). urgent help please @Knightabhi . image image

use the latest release of https://www.npmjs.com/package/react-google-drive-picker, it is working fine for me.