Closed lokeswarisatyanarayanan closed 3 years ago
Have a look at gdrive.files.getMetadata()
.
I tried that. It returns an empty object with both queryParameters passed and no query parameters
This code works for me.
function App() {
useEffect(() => {
GoogleSignin.configure({
scopes: [
"https://www.googleapis.com/auth/drive",
"https://www.googleapis.com/auth/drive.appfolder"
]});
(async () => {
try {
await GoogleSignin.hasPlayServices();
await GoogleSignin.signIn();
const gdrive = new GDrive();
gdrive.accessToken = (await GoogleSignin.getTokens()).accessToken;
console.log(await gdrive.files.getMetadata(
fileId, {
fields: "webViewLink"
}
));
} catch (error) {
console.log("oops", error.toString());
}
Is your setup correct? Can you write or read files?
It works! it was the scopes!
Thank you so much for the quick turn around time.
I am unable to get the web view link to the file. I am using the get method available. But there is no example/clear documentation with respect to how to use it to get the required data.
const getFile = async (fileId) => { const gdrive = new GDrive(); gdrive.accessToken = (await GoogleSignin.getTokens()).accessToken; try { let queryParams = { fields : "webViewLink", } let list = await gdrive.files.get(fileId, queryParams) console.log(list) } catch (error) { console.log(JSON.stringify(error)) } }