Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GDrive share doesn't load properly #255

Closed
sorawee opened this issue Nov 25, 2017 · 3 comments
Closed

GDrive share doesn't load properly #255

sorawee opened this issue Nov 25, 2017 · 3 comments

Comments

@sorawee
Copy link
Contributor

sorawee commented Nov 25, 2017

This is a pretty long GIF, but it describes what happens best.

https://giphy.com/gifs/xT0xeyfEG85YhRTy24/fullscreen

That is, a shared file (not the original code file) is occasionally loaded as a blank file in #editor mode. But it is always loaded as a blank file in #share mode. The permission of the file is correct. The console doesn't have any error. This happens across browsers (Firefox 57 and Vivaldi / Chrome 62)

The problematic URL: https://code.pyret.org/editor#share=0Bxr4FfLa3goORTBQSmRfOEk3eHM

Note that this link is the stencil file for the interp assignment that we gave to students two months ago, so it definitely used to work.

@sorawee
Copy link
Contributor Author

sorawee commented Nov 25, 2017

It seems the GIF got trimmed. Here's the full version:

https://www.dropbox.com/s/xlflw36456ukomj/Peek%202017-11-25%2018-15.mp4

@jpolitz
Copy link
Member

jpolitz commented Nov 26, 2017 via email

@jpolitz
Copy link
Member

jpolitz commented Nov 26, 2017

Yeah this is in direct conflict with a fix I made earlier this fall and pushed out recently.

Here's the crux of the issue:

  1. The Drive API forces you to set the authorization token to null before sending requests for public on the web files, as documented by the Drive team here (https://plus.google.com/u/0/+JoeGibbsPolitz/posts/7xLaiAMUP8q?cfem=1https://plus.google.com/u/0/+JoeGibbsPolitz/posts/7xLaiAMUP8q?cfem=1)
  2. As far as I can tell, the authorization token is a global mutable property of the Google Drive API; you manipulate it with a method called setToken. This property is read inside the library whenever you execute a request to determine which credential to send with the request.
  3. When you execute a request, the result is a promise for when the request completes (whether it succeeds or fails).
  4. There is no event for the request being sent, which might help tell you when to set the authorization token back.
  5. Deep in the guts of the gapi system, it appears (screenshot below) that there is a setTimeout wrapped around the sending of the request.

image

As a result of 1-5, the two obvious ideas don't work:

  1. If you set the credential back immediately after calling execute, this issue results, where the credential is set immediately to null before the request even goes out.
  2. If you set the credential back when the request completes, then any requests that go out in the meantime don't have the access token correctly set. This causes huge issues where changing the order of my-gdrive and shared-gdrive imports has bizarre effects, because CPO will make parallel requests to Drive to shorten wait times.

Now I'm thinking that using a setTimeout wrapped around a thunk that sets the credential back might have the right properties of updating it on the right turn, even with multiple requests in parallel. I'll give that a shot, but I wanted to write this all down while it was fresh in my mind; this issue has bounced around on email and slack but not had a clear writeup on Github before.

jpolitz added a commit that referenced this issue Jul 29, 2021
- Add a parameter "scopes" to /login, which can be "full" to indicate using the
  full set
- Add a session parameter "scopes" to remember which set of scopes the user is
  using
- Set the default set to just email, drive.file, and drive.connect
- As a consequence of the smaller set, tell load-spreadsheet to *not* include
  auth information for logged in users, for the same reasons as #255. That is,
  logged in users without the spreadsheet scope can't see public spreadsheets,
  but our API key can if we don't include the access_token
- Add a menu item to trigger the new /login logic via a call to reauth() with
  an extra parameter to ask for full scopes
- Rearrange the Bonnie menu and add a View menu; the Bonnie menu was getting
  huge and unweildy. View now contains the keyboard shortcuts, theme, and font,
  Bonnie has everything else.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants