Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Google Drive
Started by Michael W. Aug 22 2016 05:55 PM

31 replies to this topic
release lua android ios tvos win32 macos
[TOPIC CONTROLS]
Page 1 of 2 1 2
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Michael W.

[GLOBAL: userInfoPane.html]
Michael W.
  • Contributor

  • 276 posts
  • Alumni

Google Drive

by scottrules44


View and activate on the Corona Store


This plugins integrates Google Drive™, a places to store and manage files.

Documentation

[TOPIC: post.html]
#2

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,822 posts
  • Enterprise

:)
  • Danny likes this

[TOPIC: post.html]
#3

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,822 posts
  • Enterprise

Google cloud save has been added to this plugin. The demo, docs, and plugin have been updated. To check if you are running this version please use print(drive.version) -- should be 2.0 if you are using lastest version

[TOPIC: post.html]
#4

gc34

[GLOBAL: userInfoPane.html]
gc34
  • Observer

  • 12 posts
  • Corona SDK

This plugin let app users access their OWN (previously created) Google Drive account, or let app users access only to MY (app developer) account?

 

Thanks.



[TOPIC: post.html]
#5

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,822 posts
  • Enterprise

The user has to have a google account and the data is stored in a private section of Google drive.

[TOPIC: post.html]
#6

gc34

[GLOBAL: userInfoPane.html]
gc34
  • Observer

  • 12 posts
  • Corona SDK

I had a problem compiling example, because simulator didn't find modules googleDrive, etc. Logged to "Plugins" directory, extracted zip plugin file, moved all file extracted from "/Plugins/plugin" to "/Plugins" and now example can start without problems.



[TOPIC: post.html]
#7

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,822 posts
  • Enterprise

That is odd



[TOPIC: post.html]
#8

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,822 posts
  • Enterprise

That is my fault, Let me do a quick update



[TOPIC: post.html]
#9

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,822 posts
  • Enterprise

I had a problem compiling example, because simulator didn't find modules googleDrive, etc. Logged to "Plugins" directory, extracted zip plugin file, moved all file extracted from "/Plugins/plugin" to "/Plugins" and now example can start without problems.

This was just pushed, give it an hour and it should be working



[TOPIC: post.html]
#10

gc34

[GLOBAL: userInfoPane.html]
gc34
  • Observer

  • 12 posts
  • Corona SDK

OK:

 

print (drive.version) ---> 2.0

 

Ok:

 

In main.lua ---> local drive = require("plugin.googleDrive")

 

This validates Google user and redirects. No problem now.


  • Scott Harrison likes this

[TOPIC: post.html]
#11

gc34

[GLOBAL: userInfoPane.html]
gc34
  • Observer

  • 12 posts
  • Corona SDK

Sorry, me again...

 

I can in fact upload a .zip file, (i.e. prueba.zip, about 10 Mbyte). The source file in device is tested OK. The uploaded file to Drive looks like a corrupted file. Should I change the MIME type in request or any other feature? Thanks.



[TOPIC: post.html]
#12

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,822 posts
  • Enterprise

Sorry, me again...

I can in fact upload a .zip file, (i.e. prueba.zip, about 10 Mbyte). The source file in device is tested OK. The uploaded file to Drive looks like a corrupted file. Should I change the MIME type in request or any other feature? Thanks.


Are you uploading to app folder or just main drive
  • Scott Harrison likes this

[TOPIC: post.html]
#13

gc34

[GLOBAL: userInfoPane.html]
gc34
  • Observer

  • 12 posts
  • Corona SDK

Just main drive.



[TOPIC: post.html]
#14

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,822 posts
  • Enterprise

Try setting mimeType to application/zip

[TOPIC: post.html]
#15

gc34

[GLOBAL: userInfoPane.html]
gc34
  • Observer

  • 12 posts
  • Corona SDK

No success. I will keep on trying later. I think file has been base-64 encoded, and embedded into a plain (application/json???) file...
I'll post if i am able to get it.
 
 
By the way, this is content of uploaded file:
 
 
 
--MPFD-c7438d84ddfd075629f3b83aaf5fee687407b7a2
Content-Type: application/json; charset=UTF-8"
 
{"name":"prueba"}
--MPFD-c7438d84ddfd075629f3b83aaf5fee687407b7a2
Content-Type: application/json; charset=UTF-8"
 
{"parents":["appDataFolder"]}
--MPFD-c7438d84ddfd075629f3b83aaf5fee687407b7a2
content-disposition: form-data; name="prueba"; filename="prueba.zip"
Content-Type: application/zip
Content-Transfer-Encoding: base64
 
UEsDBBQAAAAIAHucHUkv2b59JR4AAIoeAAAOAAAASWNvbi02MEAzeC5wbmdVWQVUlO0SRkBEBKSk
c5HullaWFlhSumFZQEK6+UE6pGspaZYUpEFAlu5OCelwaRCQuN9/89w9O7tnz35vzTwz88y8kepq...
 
(here continues all base-64 encoded zip file)


[TOPIC: post.html]
#16

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,822 posts
  • Enterprise

I'll take a look when I get to my computer

[TOPIC: post.html]
#17

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,822 posts
  • Enterprise

 

No success. I will keep on trying later. I think file has been base-64 encoded, and embedded into a plain (application/json???) file...
I'll post if i am able to get it.
 
 
By the way, this is content of uploaded file:
 
 
 
--MPFD-c7438d84ddfd075629f3b83aaf5fee687407b7a2
Content-Type: application/json; charset=UTF-8"
 
{"name":"prueba"}
--MPFD-c7438d84ddfd075629f3b83aaf5fee687407b7a2
Content-Type: application/json; charset=UTF-8"
 
{"parents":["appDataFolder"]}
--MPFD-c7438d84ddfd075629f3b83aaf5fee687407b7a2
content-disposition: form-data; name="prueba"; filename="prueba.zip"
Content-Type: application/zip
Content-Transfer-Encoding: base64
 
UEsDBBQAAAAIAHucHUkv2b59JR4AAIoeAAAOAAAASWNvbi02MEAzeC5wbmdVWQVUlO0SRkBEBKSk
c5HullaWFlhSumFZQEK6+UE6pGspaZYUpEFAlu5OCelwaRCQuN9/89w9O7tnz35vzTwz88y8kepq...
 
(here continues all base-64 encoded zip file)

 

I just did a working test

 

Screen%20Shot%202016-08-31%20at%201.09.0

local fileName = "test.zip"
	drive.request("https://www.googleapis.com/upload/drive/v3/files/", "POST", function ( e )
		print(e.response)
	end, {uploadType= "multipart"}, {name = fileName}, fileName, system.ResourceDirectory, "application/zip", fileName )


[TOPIC: post.html]
#18

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,822 posts
  • Enterprise

Windows support added for web view added in the recent daily builds.

[TOPIC: post.html]
#19

CesarHernandez

[GLOBAL: userInfoPane.html]
CesarHernandez
  • Enthusiast

  • 80 posts
  • Corona SDK

Dear Scott,

 

I think this is the correct place to speak about this plugging and possible bugs.

 

1st. Will this plug support the new policies for Google for the next April 20th ?

 

(https://developers.googleblog.com/2016/08/modernizing-oauth-interactions-in-native-apps.html)

The rollout schedule for the deprecation of web-views for OAuth requests to Google is as follows. Starting October 20, 2016, we will prevent new OAuth clients from using web-views on platforms with a viable alternative, and will phase in user-facing notices for existing OAuth clients. On April 20, 2017, we will start blocking OAuth requests using web-views for all OAuth clients on platforms where viable alternatives exist.

 

 

2. All names for the files uploaded to the application folder lost his own name, and change to 'Untitled'. This make impossible to get the correct ID for the file we need to download.

 

 

EXAMPLE:

 

drive.request("https://www.googleapis.com/drive/v3/files/", "GET", function ( e ) 

print(e.response)
end, {spaces= "appDataFolder"} )
 
 
GIVES THIS ANSWER (I have uploaded 2 files)
 
 
{
 "kind": "drive#fileList",
 "files": [
  {
   "kind": "drive#file",
   "id": "1gi4QMQ12wZkI1wMcBic1OgM8cHLpZhqk37-2ZLhVn-KO",
   "name": "Untitled",
   "mimeType": "application/octet-stream"
  },
  {
   "kind": "drive#file",
   "id": "11uoK3859IMBFeYtRp4SgixXrOe7klttXXudpbwfX0_6X",
   "name": "Untitled",
   "mimeType": "application/octet-stream"
  }
 ]
}

 

 

Note that the name is 'Untitled' for both files. Not possible to identify the correct file to download.

 

I think this is a bug dear.

 

 

3. Is there any way to create folders to upload files to?

Google explain that need to change the mimeType to

mimeType = "application/vnd.google-apps.folder"

 

But I have been testing and the mime type always is the same. Any way to create folders by this way or other?

 

 

 

Thanks again for your great job.

 

 



[TOPIC: post.html]
#20

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,822 posts
  • Enterprise

Dear Scott,

 

I think this is the correct place to speak about this plugging and possible bugs.

 

1st. Will this plug support the new policies for Google for the next April 20th ?

 

(https://developers.googleblog.com/2016/08/modernizing-oauth-interactions-in-native-apps.html)

The rollout schedule for the deprecation of web-views for OAuth requests to Google is as follows. Starting October 20, 2016, we will prevent new OAuth clients from using web-views on platforms with a viable alternative, and will phase in user-facing notices for existing OAuth clients. On April 20, 2017, we will start blocking OAuth requests using web-views for all OAuth clients on platforms where viable alternatives exist.

 

 

2. All names for the files uploaded to the application folder lost his own name, and change to 'Untitled'. This make impossible to get the correct ID for the file we need to download.

 

 

EXAMPLE:

 

drive.request("https://www.googleapis.com/drive/v3/files/", "GET", function ( e ) 

print(e.response)
end, {spaces= "appDataFolder"} )
 
 
GIVES THIS ANSWER (I have uploaded 2 files)
 
 
{
 "kind": "drive#fileList",
 "files": [
  {
   "kind": "drive#file",
   "id": "1gi4QMQ12wZkI1wMcBic1OgM8cHLpZhqk37-2ZLhVn-KO",
   "name": "Untitled",
   "mimeType": "application/octet-stream"
  },
  {
   "kind": "drive#file",
   "id": "11uoK3859IMBFeYtRp4SgixXrOe7klttXXudpbwfX0_6X",
   "name": "Untitled",
   "mimeType": "application/octet-stream"
  }
 ]
}

 

 

Note that the name is 'Untitled' for both files. Not possible to identify the correct file to download.

 

I think this is a bug dear.

 

 

3. Is there any way to create folders to upload files to?

Google explain that need to change the mimeType to

mimeType = "application/vnd.google-apps.folder"

 

But I have been testing and the mime type always is the same. Any way to create folders by this way or other?

 

 

 

Thanks again for your great job.

A lot of stuff there

let me try to break it down

 

1. I not received anything on mac simulator, I am looking into this. I think iOS is the major problem. I will try to implement slowly as time goes along. 

 

as for the other stuff I just want to address that way plugin is, it is designed to allow access to the drive rest api. So this "bug" is not with plugin self, it is the way it's used. It like making the comparison that the network api are broken because I am getting server errors. It could be networking apis, but it is mostly likely the way its being used or the server.

 

 I have been trying myself and I cannot get it working. I honestly know just as much as you do about every google drive api. I feel this google bug based on the way google drive documentation is written. 



[TOPIC: post.html]
#21

thomas6

[GLOBAL: userInfoPane.html]
thomas6
  • Contributor

  • 982 posts
  • Corona SDK

Hi Scott,

 

Three things:

 

1) I hope the Corona engineers will step in and talk about how they intend to deal with the deprecation of OAuth through WebViews, since I'm assuming you (like myself) use this method for authentication.

2) I found the Google API Playground invaluable for making things work. The documentation in itself is far from enough to understand things and get them working. The API PlayGround is amazing and helps a lot.

3) If you want, I can share my Google Calendar stuff with you, so you can see some of the REST and JSON trickery.



[TOPIC: post.html]
#22

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,822 posts
  • Enterprise

Hi Scott,

 

Three things:

 

1) I hope the Corona engineers will step in and talk about how they intend to deal with the deprecation of OAuth through WebViews, since I'm assuming you (like myself) use this method for authentication.

2) I found the Google API Playground invaluable for making things work. The documentation in itself is far from enough to understand things and get them working. The API PlayGround is amazing and helps a lot.

3) If you want, I can share my Google Calendar stuff with you, so you can see some of the REST and JSON trickery.

 

Thanks, for this.

 

1. I don't think they will, my guess is the web pop ups and safari web view for iOS will work. 

2/3. I understand how the api work, thanks for the offer, I made this plugin in my free time. The main goal of the plugin was to make it easier to use the google drive api. 

 

I have decide to open source this plugin btw https://github.com/scottrules44/google-drive-source



[TOPIC: post.html]
#23

thomas6

[GLOBAL: userInfoPane.html]
thomas6
  • Contributor

  • 982 posts
  • Corona SDK

Hey Scott! Thanks - I saw your mail answering my other OAuth post as well. The native web-PopUp looks like a solution for my problem (depending on how well it's implemented, but I'm hopeful!).

 

Very cool of you to open source your stuff. I will definitely share my calendar stuff as well, but at the moment (due to lack of time) all I can do is an undocumented code dump, and that might confuse more than it would help!



[TOPIC: post.html]
#24

nick_sherman

[GLOBAL: userInfoPane.html]
nick_sherman
  • Corona Geek

  • 1,868 posts
  • Corona SDK

Just started trying to implement this.

 

I managed to log in ok, but when I restarted the app "drive.haveRefreshToken" is true so the webview doesn't appear, but I am not logged in so can't make any requests (get 'not signed in' error returned).



[TOPIC: post.html]
#25

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,822 posts
  • Enterprise

I cannot reproduce this, can you provide a sample




[topic_controls]
Page 1 of 2 1 2
 
[/topic_controls]

Also tagged with one or more of these keywords: release, lua, android, ios, tvos, win32, macos